diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-11-08 16:29:20 +0100 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-11-08 16:29:20 +0100 |
| commit | 7213eaadd63c097ad5f01605fafeb4c0c9d6f986 (patch) | |
| tree | 9bd688d4553f365b66564295146d9a48bff504c9 | |
| parent | 4d0dbceaf93835954e985a43062597be7d9bc08d (diff) | |
Fixed up loading/saving selections
| -rw-r--r-- | bindings.bb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/bindings.bb b/bindings.bb index e87c7b2..dc66549 100644 --- a/bindings.bb +++ b/bindings.bb @@ -67,11 +67,13 @@ v,V,Space: # Toggle selection at cursor Escape: # Clear selection bb +deselect Ctrl-s: # Save the selection - [ $# -gt 0 ] && ask savename "Save selection as: " && printf '%s\0' "$@" > ~/.config/bb/"$savename" + [ $# -gt 0 ] && ask savename "Save selection as: " || exit 1 + if ! expr "$savename" : ".*\.sel" >/dev/null; then savename="$savename.sel"; fi + printf '%s\0' "$@" > ~/.config/bb/"$savename" Ctrl-o: # Open a saved selection - loadpath="$(printf '%s\0' ~/.config/bb/* | pick "Load selection: ")" && - [ -e "$loadpath" ] && bb +deselect && - while IFS= read -r -d $'\0'; do bb +select:"$REPLY"; done < "$loadpath" + [ $# -gt 0 ] && ! confirm "The current selection will be discarded. " && exit 1 + loadpath="$(find ~/.config/bb/ -name '*.sel' -exec basename -az '{}' ';' | pick "Load selection: ")" && + cat ~/.config/bb/"$loadpath" | bb +deselect +select: J: # Spread selection down bb +spread:+1 K: # Spread selection up |
