Added better doc for unscroll

This commit is contained in:
Bruce Hill 2019-11-08 15:46:00 +01:00
parent b9e2bc280b
commit e60e5472b4
2 changed files with 6 additions and 5 deletions

3
bb.h
View File

@ -264,7 +264,8 @@ static const char *bbcmdfn = "bb() {\n"
" printf \"%s\\0\" \"$arg\" >> $BBCMD;\n"
" done;\n"
"}\n"
"butt() {\n"
// This shell function overwrites the lines above the cursor instead of scrolling the screen
"unscroll() {\n"
" input=\"$(cat)\"\n"
" printf \"\\033[$(echo \"$input\" | wc -l)A\\033[J\" >/dev/tty\n"
" echo \"$input\"\n"

View File

@ -108,17 +108,17 @@ d,Delete: # Delete a file
printf "\033[1mDeleting \033[33m$BBCURSOR\033[0;1m...\033[0m " && confirm &&
rm -rf "$BBCURSOR" && bb +deselect:"$BBCURSOR" +refresh
D: # Delete all selected files
[ $# -gt 0 ] && printf "\033[1mDeleting the following:\n\033[33m$(printf ' %s\n' "$@")\033[0m" | butt | more &&
[ $# -gt 0 ] && printf "\033[1mDeleting the following:\n\033[33m$(printf ' %s\n' "$@")\033[0m" | unscroll | more &&
confirm && rm -rf "$@" && bb +deselect +refresh
Ctrl-v: # Move files here
printf "\033[1mMoving the following to here:\n\033[33m$(printf ' %s\n' "$@")\033[0m" | butt | more &&
printf "\033[1mMoving the following to here:\n\033[33m$(printf ' %s\n' "$@")\033[0m" | unscroll | more &&
confirm && printf "\033[1G\033[KMoving..." && mv -i "$@" . && printf "done." &&
bb +deselect +refresh && for f; do bb +sel:"$(basename "$f")"; done
c: # Copy a file
printf "\033[1mCreating copy of \033[33m$BBCURSOR\033[0;1m...\033[0m " &&
confirm && cp -ri "$BBCURSOR" "$BBCURSOR.copy" && bb +refresh
C: # Copy all selected files here
[ $# -gt 0 ] && printf "\033[1mCopying the following to here:\n\033[33m$(printf ' %s\n' "$@")\033[0m" | butt | more &&
[ $# -gt 0 ] && printf "\033[1mCopying the following to here:\n\033[33m$(printf ' %s\n' "$@")\033[0m" | unscroll | more &&
confirm && printf "\033[1G\033[KCopying..." &&
for f; do if [ "./$(basename "$f")" -ef "$f" ]; then
cp -ri "$f" "$f.copy" || break;
@ -163,7 +163,7 @@ Ctrl-r: # Regex rename files
command -v rename >/dev/null ||
{ printf '\033[31;1mThe `rename` command is not installed. Please install it to use this key binding.\033[0m\n'; pause; exit; };
ask patt "Replace pattern: " && ask rep "Replacement: " &&
printf "\033[1mRenaming:\n\033[33m$(if [ $# -gt 0 ]; then rename -nv "$patt" "$rep" "$@"; else rename -nv "$patt" "$rep" *; fi)\033[0m" | butt | more &&
printf "\033[1mRenaming:\n\033[33m$(if [ $# -gt 0 ]; then rename -nv "$patt" "$rep" "$@"; else rename -nv "$patt" "$rep" *; fi)\033[0m" | unscroll | more &&
confirm || exit 1
if [ $# -gt 0 ]; then rename -i "$patt" "$rep" "$@"; else rename -i "$patt" "$rep" *; fi
bb +deselect +refresh