From b91dbdd3d076752478ca68a2d7b8c36c2a5a3549 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 15 Jun 2019 14:14:05 -0700 Subject: Added $BBDOTFILES, and updated bindings to use it properly. Removed the `+select:*` and `+deselect:*` in favor of just using shell commands for those functions. --- config.def.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'config.def.h') diff --git a/config.def.h b/config.def.h index a388410..09b23fe 100644 --- a/config.def.h +++ b/config.def.h @@ -17,6 +17,7 @@ no files are selected, the full path of the file under the cursor $BBCURSOR: the full path of the file under the cursor $BBSELECTED: "1" if any files are selected, otherwise "" + $BBDOTFILES: "1" if files beginning with "." are visible in bb, otherwise "" $BB_DEPTH: the number of `bb` instances deep (in case you want to run a shell and have that shell print something special in the prompt) $BBCMD: a file to which `bb` commands can be written (used internally) @@ -28,7 +29,7 @@ ..:[01] Whether to show ".." in each directory cd: Navigate to columns: Change which columns are visible, and in what order - deselect:|* Deselect or all ("*") + deselect: Deselect dotfiles:[01] Whether dotfiles are visible goto: Move the cursor to (changing directory if needed) interleave:[01] Whether or not directories should be interleaved with files in the display @@ -38,8 +39,8 @@ quit Quit bb refresh Refresh the file listing scroll: Scroll the view a numeric amount - select:|* Select or all visible files in current directory ("*") - sort:([+-]method)+ List of sortings (if equal on one, move to the next) + select: Select + sort:([+-]method)+ Set sorting method (+: normal, -: reverse), additional methods act as tiebreaker spread: Spread the selection state at the cursor toggle: Toggle the selection status of @@ -186,10 +187,12 @@ binding_t bindings[] = { #endif B("Open")" file/directory"}, {{' ','v','V'}, "+toggle", B("Toggle")" selection"}, - {{KEY_ESC}, "+deselect:*", B("Clear")" selection"}, + {{KEY_ESC}, "bb +deselect: \"$@\"", B("Clear")" selection"}, {{'e'}, "$EDITOR \"$@\" || "PAUSE, B("Edit")" file in $EDITOR"}, - {{KEY_CTRL_F}, "bb \"+goto:$(find | "PICK("Find: ", "")")\"", B("Search")" for file"}, - {{'/'}, "bb \"+goto:$(ls -A | "PICK("Pick: ", "")")\"", B("Pick")" file"}, + {{KEY_CTRL_F}, "bb \"+goto:$(if test $BBDOTFILES; then find -mindepth 1; else find -mindepth 1 ! -path '*/.*'; fi " + "| "PICK("Find: ", "")")\"", B("Search")" for file"}, + {{'/'}, "bb \"+goto:$(if test $BBDOTFILES; then find -mindepth 1 -maxdepth 1; else find -mindepth 1 -maxdepth 1 ! -path '*/.*'; fi " + "| "PICK("Pick: ", "")")\"", B("Pick")" file"}, {{'d', KEY_DELETE}, "rm -rfi \"$@\" && bb '+deselect:*' +r ||" PAUSE, B("Delete")" files"}, {{'D'}, SPIN("rm -rf \"$@\"")" && bb '+deselect:*' +r ||" PAUSE, B("Delete")" files (without confirmation)"}, {{'M'}, SPIN("mv -i \"$@\" . && bb '+deselect:*' +r && for f; do bb \"+sel:$(basename \"$f\")\"; done")" || "PAUSE, @@ -243,7 +246,9 @@ binding_t bindings[] = { {{'g', KEY_HOME}, "+move:0", "Go to "B("first")" file"}, {{'G', KEY_END}, "+move:100%n", "Go to "B("last")" file"}, {{KEY_F5, KEY_CTRL_R}, "+refresh", B("Refresh")}, - {{KEY_CTRL_A}, "+select:*", B("Select all")" files in current directory"}, + {{KEY_CTRL_A}, "if test $BBDOTFILES; then find -mindepth 1 -maxdepth 1 -print0; else find -mindepth 1 -maxdepth 1 ! -path '*/.*' -print0; fi " + "| xargs -0 bb +sel:", + B("Select all")" files in current directory"}, {{KEY_PGDN}, "+scroll:+100%", B("Page down")}, {{KEY_PGUP}, "+scroll:-100%", B("Page up")}, {{KEY_CTRL_D}, "+scroll:+50%", B("Half page down")}, -- cgit v1.2.3