Added some simplifications/tweaks

This commit is contained in:
Bruce Hill 2020-06-04 00:05:18 -07:00
parent 68095db20f
commit 5eb79c076c
4 changed files with 13 additions and 13 deletions

View File

@ -17,9 +17,9 @@
make
sudo make install
To run `bb`, it's expected that you have some basic unix tools:
`basename`, `cat`, `cp`, `echo`, `find`, `kill`, `less`, `ln`, `mkdir`, `more`,
`mv`, `printf`, `read`, `rm`, `sed`, `sh`, `touch`, `tput`, `tr`.
To run `bb`, it's expected that you have some basic unix tools: `cat`, `cp`,
`echo`, `find`, `kill`, `less`, `ln`, `mkdir`, `more`, `mv`, `printf`, `read`,
`rm`, `sed`, `sh`, `tput`, `tr`.
## Usage

View File

@ -24,7 +24,7 @@ else
if [ "$(uname)" = "Darwin" ]; then
read -e REPLY </dev/tty >/dev/tty
else
read REPLY </dev/tty >/dev/tty
read -r REPLY </dev/tty >/dev/tty
fi
echo $REPLY
fi

View File

@ -122,15 +122,15 @@ echo "bbcmd glob:'$BBGLOB' sort:'$BBSORT' columns:'$BBCOLUMNS' $BBINTERLEAVE" >
## Ctrl-s: Save the selection
[ $# -gt 0 ]
savename="$(bbask "Save selection as: ")"
savename="${savename%.sel}.sel"
mkdir -p "$XDG_DATA_HOME"/bb
if ! expr "$savename" : ".*\.sel" >/dev/null; then savename="$savename.sel"; fi
printf '%s\0' "$@" > "$XDG_DATA_HOME"/bb/"$savename"
printf '%s\0' "$@" > "$XDG_DATA_HOME/bb/$savename"
## 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: ")"
cat "$XDG_DATA_HOME"/bb/"$loadpath" | bbcmd deselect select:
cat "$XDG_DATA_HOME/bb/$loadpath" | bbcmd deselect select:
## J: Spread selection down
bbcmd spread:+1
@ -188,7 +188,7 @@ printf "\033[1G\033[KMoving..."
mv -i "$@" .
printf "done."
bbcmd deselect refresh
for f; do bbcmd sel:"$(basename "$f")"; done
bbcmd sel: "${@##*/}"
## c: Copy a file
[ $# -gt 0 ]
@ -196,7 +196,7 @@ printf "\033[1mCopying the following to here:\n\033[33m$(printf ' %s\n' "$@")\0
bbconfirm
printf "\033[1G\033[KCopying..."
for f; do
if [ "./$(basename "$f")" -ef "$f" ]; then
if [ "./${f##*/}" -ef "$f" ]; then
cp -ri "$f" "$f.copy" || break
else cp -ri "$f" . || break; fi
done
@ -206,7 +206,7 @@ bbcmd refresh
## Ctrl-n: New file/directory
case "$(printf '%s\0' File Directory | bbpick "Create new: ")" in
File)
name="$(bbask "New File: ")" && touch -- "$name"
name="$(bbask "New File: ")" && printf '' >"$name"
;;
Directory)
name="$(bbask "New Directory: ")" && mkdir -- "$name"
@ -225,7 +225,7 @@ case "$(bbtargets "$BBCURSOR" "$@")" in
both) set -- "$BBCURSOR" "$@";;
esac
for f; do
newname="$(bbask "Rename $(printf "\033[33m%s\033[39m" "$(basename "$f")"): " "$(basename "$f")")" || break
newname="$(bbask "Rename $(printf "\033[33m%s\033[39m" "${f##*/}"): " "${f##*/}")" || break
r="$(dirname "$f")/$newname"
[ "$r" = "$f" ] && continue
[ -e "$r" ] && printf "\033[31;1m$r already exists! It will be overwritten.\033[0m "

View File

@ -17,11 +17,11 @@ fi
case "$PICKER" in
fzf*)
printf '\033[3A\033[?25h' >/dev/tty
fzf --read0 --height=4 --prompt="$(printf "$1")"
fzf --read0 --height=6 --prompt="$(printf "$1")"
;;
fzy*)
printf '\033[3A\033[?25h' >/dev/tty
tr '\0' '\n' | fzy --lines=3 --prompt="$(printf "\033[1m$1\033[0m")"
tr '\0' '\n' | fzy --lines=5 --prompt="$(printf "\033[1m$1\033[0m")"
;;
ask*)
ask --read0 --prompt="$(printf "$1\033[?25h")"