# bm.fish — shell wrapper for bmrk (fish)
#
# The TUI renders to stderr (visible in terminal); stdout carries the path.
# This wrapper captures stdout, and if it is a directory, cd's to it.
# All other output (help, version, bookmark list, confirmations) is printed normally.
#
# INSTALLATION
# ────────────
# Fish autoloads functions by filename, so this file can be copied or symlinked
# directly into the fish functions directory:
#
# cp /path/to/bm.fish ~/.config/fish/functions/bm.fish
#
# — or symlink to keep it in sync with the repo:
#
# ln -s /path/to/bmrk/bm.fish ~/.config/fish/functions/bm.fish
#
# Fish picks up functions in that directory automatically — no reload step needed.
function bm
if test "$argv[1]" = "-"
if test -n "$BMRK_PREV_DIR" -a -d "$BMRK_PREV_DIR"
set prev $BMRK_PREV_DIR
set -gx BMRK_PREV_DIR $PWD
cd $prev
else
echo "bm: no previous directory" >&2; return 1
end
return
end
set r (bmrk $argv)
if test -d "$r"
set -gx BMRK_PREV_DIR $PWD; cd $r
else if test -n "$r"
printf '%s\n' $r
end
end