commit 620f31d71474068f89cca9a95648887e7b049f4f
parent c70ac1789284ad1e1566c28147849a561ea80051
Author: Sven Möller <sven-moeller@outlook.de>
Date: Wed, 22 Dec 2021 21:03:03 +0100
Add function to open random unread link, cleanup
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/bin/.local/bin/bm b/bin/.local/bin/bm
@@ -29,8 +29,8 @@ add () {
"$NOTIFY" "Bookmark added! ($title)"
}
-list () {
- cat -n "$BM_DIR/$1"
+random () {
+ shuf -n 1 "$BM_DIR/unread" | awk '{print $1}' | xargs xdg-open
}
move () {
@@ -51,7 +51,7 @@ interactive () {
list="$1"
actions="open\narchive\nfavorite\nunread\ndelete\n"
while :; do
- line="$(list "$list" | "$selector" | awk '{print $1}')"
+ line="$(cat -n "$BM_DIR/$1" | "$selector" | awk '{print $1}')"
if [ -z "$line" ]; then exit; fi
action="$(printf "$actions" | grep -v "$list" | "$selector")"
if [ -z "$action" ]; then exit; fi
@@ -103,7 +103,7 @@ if [ -z "$1" ]; then "$0" "unread"; exit; fi
case "$1" in
unread|favorite|archive)
interactive "$1" ;;
- git|sync|html)
+ git|sync|html|random)
"$@"; exit ;;
http://*|https://*)
add "$1" "$2"; exit ;;