commit 33b169c7d212442c253867b8cedcd7f4eaf3400d Spenser Truex <truex@equwal.com> 2026-09-21 02:13:48 -0700 bm: remove the Ctrl-T tag filter A separate tag menu does not fit bm. fzf already searches the tags column, so typing a tag shows its bookmarks. The -t option stays, for scripts such as bm --tag code --list | bm-check -.
README | 6 ++++-- TODO | 2 +- bm | 22 ++-------------------- test/run.sh | 20 +++----------------- 4 files changed, 10 insertions(+), 40 deletions(-)
diff --git a/README b/README index 9de38dd..e313e90 100644 --- a/README +++ b/README @@ -99,10 +99,12 @@ Closing the second menu goes back to the list, closing the list leaves. With fzf (no display, or SBM_MENU=fzf) it is one screen: the bookmark under the cursor is previewed live, and keys do the rest. - ENTER open ctrl-a add ctrl-t filter by tag - ctrl-y copy ctrl-d delete (asks) ctrl-s next sort order + ENTER open ctrl-a add ctrl-s next sort order + ctrl-y copy ctrl-d delete (asks) ESC leave ctrl-e edit +To see the bookmarks of a tag, type the tag. fzf searches the tags too. + == Web search == In the list, and in "bm -o", text that is not a bookmark is not wasted: diff --git a/TODO b/TODO index cc69375..0794431 100644 --- a/TODO +++ b/TODO @@ -15,5 +15,5 @@ PREVENT DUPLICATES - [X] bookmark preview (fzf: live; dmenu: the second menu) - [X] a personal web page of the bookmarks, with search (bm-html) - [X] split into small tools; POSIX sh and POSIX utilities only -- tag filter and sort order from inside the dmenu list +- sort order from inside the dmenu list - man pages diff --git a/bm b/bm index 15dfe36..8baff33 100755 --- a/bm +++ b/bm @@ -466,23 +466,6 @@ nextorder () { esac } -# alltags: the tags of $USERTAGS and the tags that the bookmarks use. A tag -# that no bookmark uses yet is a tag too. -alltags () { - { sed 's/[ |].*//' "$USERTAGS" 2>/dev/null - awk -F'\t' 'NF && !/^#/ { print $3 }' "$BOOKMARKS" | tr ' ' '\n' - } | sed '/^$/d' | sort -u -} - -picktag () { - tag=$( { printf '(all)\n'; alltags; } | pick 'tag:') - case $tag in - '') ;; - '(all)') tagfilter= ;; - *) tagfilter=$tag ;; - esac -} - # add exits, which must not end a browsing session; and when it refuses a # duplicate the user has to get to see that before the list comes back. add_inside () { @@ -496,9 +479,9 @@ add_inside () { # copying leave it, the other keys come back to it. browse_fzf () { while :; do - header="ENTER open ^Y copy ^A add ^D delete ^E edit ^T tag [${tagfilter:-all}] ^S sort [$sortorder]" + header="ENTER open ^Y copy ^A add ^D delete ^E edit ^S sort [$sortorder]" out=$(rows | fzfrows | withpreview fzfcmd --print-query \ - --expect=ctrl-y,ctrl-a,ctrl-d,ctrl-e,ctrl-t,ctrl-s \ + --expect=ctrl-y,ctrl-a,ctrl-d,ctrl-e,ctrl-s \ --header="$header" --prompt='bookmark: ') [ -n "$out" ] || exit 1 typed=$(printf '%s\n' "$out" | sed -n 1p) @@ -507,7 +490,6 @@ browse_fzf () { case $key in ctrl-a) add_inside; continue ;; - ctrl-t) picktag; continue ;; ctrl-s) nextorder; continue ;; esac if [ -z "$url" ]; then diff --git a/test/run.sh b/test/run.sh index a5964d1..5408072 100755 --- a/test/run.sh +++ b/test/run.sh @@ -688,25 +688,11 @@ eq 'browse: ctrl-s cycles the sort order' \ "$(grep -o 'sort \[[a-z]*\]' "$SBM_TEST_LOG" | paste -sd ' ' -)" \ 'sort [used] sort [recent] sort [url]' -rm -f "$work/opened" -answers 'ctrl-t:' 'sec' 'enter:example' -fz </dev/null -eq 'browse: ctrl-t narrows to a tag' "$(cat "$work/opened")" 'https://a.example' - -# The fake fzf gives the first tag that contains the typed text, else the -# typed text. No bookmark has i2p, but the tag file has it. +# Tags need no key of their own: fzf matches the tags column like the rest. : > "$SBM_TEST_LOG" -answers 'ctrl-t:' 'i2' '' -fz </dev/null -eq 'browse: ctrl-t offers the tags of the tag file too' \ - "$(grep -o 'tag \[[^]]*\]' "$SBM_TEST_LOG" | paste -sd ' ' -)" 'tag [all] tag [i2p]' -printf '# zzcomment\n' >> "$BOOKMARKS" -: > "$SBM_TEST_LOG" -answers 'ctrl-t:' 'zzcom' '' +answers '' fz </dev/null -eq 'browse: ctrl-t takes no tags from comment lines' \ - "$(grep -o 'tag \[[^]]*\]' "$SBM_TEST_LOG" | paste -sd ' ' -)" 'tag [all] tag [zzcom]' -seed +eq 'browse: no tag filter key' "$(grep -c -e 'ctrl-t' -e '\^T' "$SBM_TEST_LOG")" '0' answers 'ctrl-d:Zed' '' printf 'n\n' | fz 2>/dev/null