Added some simplifications/tweaks
This commit is contained in:
parent
68095db20f
commit
5eb79c076c
@ -17,9 +17,9 @@
|
|||||||
make
|
make
|
||||||
sudo make install
|
sudo make install
|
||||||
|
|
||||||
To run `bb`, it's expected that you have some basic unix tools:
|
To run `bb`, it's expected that you have some basic unix tools: `cat`, `cp`,
|
||||||
`basename`, `cat`, `cp`, `echo`, `find`, `kill`, `less`, `ln`, `mkdir`, `more`,
|
`echo`, `find`, `kill`, `less`, `ln`, `mkdir`, `more`, `mv`, `printf`, `read`,
|
||||||
`mv`, `printf`, `read`, `rm`, `sed`, `sh`, `touch`, `tput`, `tr`.
|
`rm`, `sed`, `sh`, `tput`, `tr`.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ else
|
|||||||
if [ "$(uname)" = "Darwin" ]; then
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
read -e REPLY </dev/tty >/dev/tty
|
read -e REPLY </dev/tty >/dev/tty
|
||||||
else
|
else
|
||||||
read REPLY </dev/tty >/dev/tty
|
read -r REPLY </dev/tty >/dev/tty
|
||||||
fi
|
fi
|
||||||
echo $REPLY
|
echo $REPLY
|
||||||
fi
|
fi
|
||||||
|
@ -122,15 +122,15 @@ echo "bbcmd glob:'$BBGLOB' sort:'$BBSORT' columns:'$BBCOLUMNS' $BBINTERLEAVE" >
|
|||||||
## Ctrl-s: Save the selection
|
## Ctrl-s: Save the selection
|
||||||
[ $# -gt 0 ]
|
[ $# -gt 0 ]
|
||||||
savename="$(bbask "Save selection as: ")"
|
savename="$(bbask "Save selection as: ")"
|
||||||
|
savename="${savename%.sel}.sel"
|
||||||
mkdir -p "$XDG_DATA_HOME"/bb
|
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
|
## Ctrl-o: Open a saved selection
|
||||||
[ -d "$XDG_DATA_HOME"/bb ]
|
[ -d "$XDG_DATA_HOME"/bb ]
|
||||||
[ $# -gt 0 ] && bbconfirm "The current selection will be discarded. "
|
[ $# -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: ")"
|
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
|
## J: Spread selection down
|
||||||
bbcmd spread:+1
|
bbcmd spread:+1
|
||||||
@ -188,7 +188,7 @@ printf "\033[1G\033[KMoving..."
|
|||||||
mv -i "$@" .
|
mv -i "$@" .
|
||||||
printf "done."
|
printf "done."
|
||||||
bbcmd deselect refresh
|
bbcmd deselect refresh
|
||||||
for f; do bbcmd sel:"$(basename "$f")"; done
|
bbcmd sel: "${@##*/}"
|
||||||
|
|
||||||
## c: Copy a file
|
## c: Copy a file
|
||||||
[ $# -gt 0 ]
|
[ $# -gt 0 ]
|
||||||
@ -196,7 +196,7 @@ printf "\033[1mCopying the following to here:\n\033[33m$(printf ' %s\n' "$@")\0
|
|||||||
bbconfirm
|
bbconfirm
|
||||||
printf "\033[1G\033[KCopying..."
|
printf "\033[1G\033[KCopying..."
|
||||||
for f; do
|
for f; do
|
||||||
if [ "./$(basename "$f")" -ef "$f" ]; then
|
if [ "./${f##*/}" -ef "$f" ]; then
|
||||||
cp -ri "$f" "$f.copy" || break
|
cp -ri "$f" "$f.copy" || break
|
||||||
else cp -ri "$f" . || break; fi
|
else cp -ri "$f" . || break; fi
|
||||||
done
|
done
|
||||||
@ -206,7 +206,7 @@ bbcmd refresh
|
|||||||
## Ctrl-n: New file/directory
|
## Ctrl-n: New file/directory
|
||||||
case "$(printf '%s\0' File Directory | bbpick "Create new: ")" in
|
case "$(printf '%s\0' File Directory | bbpick "Create new: ")" in
|
||||||
File)
|
File)
|
||||||
name="$(bbask "New File: ")" && touch -- "$name"
|
name="$(bbask "New File: ")" && printf '' >"$name"
|
||||||
;;
|
;;
|
||||||
Directory)
|
Directory)
|
||||||
name="$(bbask "New Directory: ")" && mkdir -- "$name"
|
name="$(bbask "New Directory: ")" && mkdir -- "$name"
|
||||||
@ -225,7 +225,7 @@ case "$(bbtargets "$BBCURSOR" "$@")" in
|
|||||||
both) set -- "$BBCURSOR" "$@";;
|
both) set -- "$BBCURSOR" "$@";;
|
||||||
esac
|
esac
|
||||||
for f; do
|
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="$(dirname "$f")/$newname"
|
||||||
[ "$r" = "$f" ] && continue
|
[ "$r" = "$f" ] && continue
|
||||||
[ -e "$r" ] && printf "\033[31;1m$r already exists! It will be overwritten.\033[0m "
|
[ -e "$r" ] && printf "\033[31;1m$r already exists! It will be overwritten.\033[0m "
|
||||||
|
@ -17,11 +17,11 @@ fi
|
|||||||
case "$PICKER" in
|
case "$PICKER" in
|
||||||
fzf*)
|
fzf*)
|
||||||
printf '\033[3A\033[?25h' >/dev/tty
|
printf '\033[3A\033[?25h' >/dev/tty
|
||||||
fzf --read0 --height=4 --prompt="$(printf "$1")"
|
fzf --read0 --height=6 --prompt="$(printf "$1")"
|
||||||
;;
|
;;
|
||||||
fzy*)
|
fzy*)
|
||||||
printf '\033[3A\033[?25h' >/dev/tty
|
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*)
|
||||||
ask --read0 --prompt="$(printf "$1\033[?25h")"
|
ask --read0 --prompt="$(printf "$1\033[?25h")"
|
||||||
|
Loading…
Reference in New Issue
Block a user