Recently Written · git

sbm-suckless

sbm before the rewrite: bookmarks in a plain file, picked with dmenu. Suckless style.

git clone https://github.com/equwal/sbm-suckless

Log | Files | Refs


commit a2a5d76a0cc524589a272390055c2ebc1e5800bd
Spenser Truex <truex@equwal.com>
2021-01-12 07:47:06 -0800

Bugfix: only copy the URL portion.

 bm | 39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/bm b/bm
index 9cf3ba7..7915a2a 100755
--- a/bm
+++ b/bm
@@ -7,29 +7,28 @@ help () {
     printf "-h, --help\n-c, --copy\n-a, --add\n-e, --edit\n"
 }
 copy () {
-    sort -t2 "$BOOKMARKS" | dmenu -l $DMENULINES -p "bookmark:" | cut -f 1 | xclip -i -selection clipboard
+    sort -t2 "$BOOKMARKS" | dmenu -l $DMENULINES -p "bookmark:" | cut -f 1 -d ' ' | xclip -i -selection clipboard
 }
-add () {
-
-}
-edit () {
-
-}
-
+# add () {
+#
+# }
+# edit () {
+#
+# }
+# plumb () {
+# }
+#
 promptflag () {
-    prompt="$(printf 'copy\nadd\nedit')"
-    action="$(dmenu -l 3 -p '$prompt')"
+    action="$(printf 'copy\nadd\nedit' | dmenu -l 3 -p 'action:')"
     [ "$action" = "copy" ] && copy
     [ "$action" = "edit" ] && edit
     [ "$action" = "add" ] && add
+    [ "$action" = "plumb" ] && plumb
 }
-argparse () {
-    arg="$1"
-    [ "$1" = '-h' ] || [ "$1" = '--help' ] && help && exit 0
-    [ "$1" = '-c' ] || [ "$1" = '--copy' ] && copy && exit 0
-    [ "$1" = '-a' ] || [ "$1" = '--add' ]  && add && exit 0
-    [ "$1" = '-e' ] || [ "$1" = '--edit' ] && edit && exit 0
-    [ -z "$1" ] && promptflag
-}
-
-[ -z "$2" ] && argparse "$1" || echo "Too many arguments: use one or none." && exit 1
+[ "$1" = '-h' ] || [ "$1" = '--help' ] && help
+[ "$1" = '-c' ] || [ "$1" = '--copy' ] && copy
+[ "$1" = '-a' ] || [ "$1" = '--add' ]  && add
+[ "$1" = '-e' ] || [ "$1" = '--edit' ] && edit
+[ "$1" = '-e' ] || [ "$1" = '--plumb' ] && plumb
+[ -z "$1" ] && promptflag
+[ -n "$2" ] && echo "Too many arguments: use one or none." && exit 1