diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-04-16 23:06:23 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-04-16 23:06:23 -0700 |
| commit | 2c44abc2c4940c9db3e76f8f24de35dd88256848 (patch) | |
| tree | f86ebc08e88becc4a24e2756c5535f16abc345d2 /scripts | |
| parent | 0597d77f3f49ac3ed1acecf88c6f6821ba166d15 (diff) | |
Deprecated "<selection>" in favor of a better system using symlinks
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/bbkeys | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/scripts/bbkeys b/scripts/bbkeys index bf5960a..ccfc374 100755 --- a/scripts/bbkeys +++ b/scripts/bbkeys @@ -36,7 +36,8 @@ bbcmd move:-1 bbcmd cd:.. ## l,Right: Enter directory -if [ -d "$BB" ]; then bbcmd cd:"$BB"; fi +if [ -d "$BB" ]; then bbcmd cd:"$BB"; +elif [ -L "$BB" ]; then bbcmd goto:"$(readlink -f "$BB")"; fi ## Ctrl-f: Search for file file="$(find . -mindepth 1 -printf '%P\0' | bbpick "Find: ")" @@ -70,7 +71,7 @@ bbcmd cd:"$mark" [ "$BBPREVPATH" ] && bbcmd cd:"$BBPREVPATH" ## ;: Show selected files -bbcmd cd:'<selection>' +printf '%s\n' "$@" | less ## 0: Go to intitial directory bbcmd cd:"$BBINITIALPATH" @@ -120,17 +121,21 @@ bbconfirm "Save the current settings? " echo "bbcmd glob:'$BBGLOB' sort:'$BBSORT' columns:'$BBCOLUMNS' $BBINTERLEAVE" > "$XDG_DATA_HOME"/bb/settings.sh ## Ctrl-s: Save the selection -[ $# -gt 0 ] savename="$(bbask "Save selection as: ")" -savename="${savename%.sel}.sel" -mkdir -p "$XDG_DATA_HOME"/bb -printf '%s\0' "$@" > "$XDG_DATA_HOME/bb/$savename" +savedir="$XDG_DATA_HOME/bb/${savename%.sel}.sel" +! [ -d "$savedir" ] || bbconfirm "Do you want to overwrite the existing save? " +rm -rf "$savedir" +[ $# -gt 0 ] && mkdir -p "$savedir" +for f; do ln -sT "$f" "$savedir/${f##*/}" || exit 1; done +echo "Saved." +bbpause ## Ctrl-o: Open a saved selection [ -d "$XDG_DATA_HOME"/bb ] [ $# -gt 0 ] && bbconfirm "The current selection will be discarded. " -loadpath="$(find "$XDG_DATA_HOME"/bb/ -mindepth 1 -name '*.sel' -printf '%P\0' | bbpick "Load selection: ")" -bbcmd deselect select: <"$XDG_DATA_HOME/bb/$loadpath" +loadpath="$(find "$XDG_DATA_HOME"/bb/ -mindepth 1 -maxdepth 1 -name '*.sel' -printf '%P\0' | bbpick "Load selection: ")" +find "$XDG_DATA_HOME/bb/$loadpath" -mindepth 1 -maxdepth 1 -printf '%l\0' | bbcmd deselect select: +bbcmd goto ## J: Spread selection down bbcmd spread:+1 |
