diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-06-12 16:57:07 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-06-12 16:57:07 -0700 |
| commit | 4bac1a740ac21c00e55ef892ce386079a71ae5a3 (patch) | |
| tree | 5e8f56dcde58c456982c980c34005ab232272878 | |
| parent | 69955d38082d5a5f47306daafeaf8c17171b0675 (diff) | |
Cleaned up commands a bit and changes 'P' from using grep for patterns
to select to 'S' to use shell globbing
| -rw-r--r-- | bb.c | 1 | ||||
| -rw-r--r-- | config.def.h | 22 |
2 files changed, 12 insertions, 11 deletions
@@ -972,6 +972,7 @@ bb_result_t execute_cmd(bb_t *bb, const char *cmd) char *value = strchr(cmd, ':'); if (value) ++value; #define set_bool(target) do { if (!value) { target = !target; } else { target = value[0] == '1'; } } while (0) + if (cmd[0] == '+') ++cmd; switch (cmd[0]) { case '.': { // +..:, +.: if (cmd[1] == '.') // +..: diff --git a/config.def.h b/config.def.h index ed06200..26fb04b 100644 --- a/config.def.h +++ b/config.def.h @@ -177,11 +177,11 @@ binding_t bindings[] = { #ifdef __APPLE__ "if test -d \"$BBCURSOR\"; then bb \"+cd:$BBCURSOR\"; " "elif test -x \"$BBCURSOR\"; then \"$BBCURSOR\"; " PAUSE "; " - "elif file -bI \"$BBCURSOR\" | grep '^\\(text/\\|inode/empty\\)' >/dev/null; then $EDITOR \"$BBCURSOR\"; " + "elif file -bI \"$BBCURSOR\" | grep -q '^\\(text/\\|inode/empty\\)'; then $EDITOR \"$BBCURSOR\"; " "else open \"$BBCURSOR\"; fi", #else "if test -d \"$BBCURSOR\"; then bb \"+cd:$BBCURSOR\"; " - "elif file -bi \"$BBCURSOR\" | grep '^\\(text/\\|inode/empty\\)' >/dev/null; then $EDITOR \"$BBCURSOR\"; " + "elif file -bi \"$BBCURSOR\" | grep -q '^\\(text/\\|inode/empty\\)'; then $EDITOR \"$BBCURSOR\"; " "else xdg-open \"$BBCURSOR\"; fi", #endif B("Open")" file/directory"}, @@ -192,7 +192,7 @@ binding_t bindings[] = { {{'/'}, "bb \"+goto:$(ls -A | "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 printf \"$(pwd)/$(basename \"$f\")\\0\"; done | xargs -0 bb +sel: || "PAUSE, + {{'M'}, SPIN("mv -i \"$@\" .")" && bb '+deselect:*' +r && for f; do bb \"+sel:$(basename \"$f\")\"; done || "PAUSE, B("Move")" files to current directory"}, {{'c'}, SPIN("cp -ri \"$@\" .")" && bb +r || "PAUSE, B("Copy")" files to current directory"}, {{'C'}, "for f; do "SPIN("cp \"$f\" \"$f.copy\"")"; done && bb +r || "PAUSE, @@ -224,19 +224,19 @@ binding_t bindings[] = { "for f; do " " renamed=\"$(dirname \"$f\")/$(basename \"$f\" | sed -E \"$patt\")\"; " " if test \"$f\" != \"$renamed\" && mv -i \"$f\" \"$renamed\" && test $BBSELECTED; then " - " printf \"+deselect:$f\\0+select:$renamed\\0\"; " + " bb \"+deselect:$f\" \"+select:$renamed\"; " " fi;" - "done | xargs -0 bb", B("Regex rename")" files"}, - {{'P'}, - ASK("patt", "Select pattern: ", "")" && ls -A | grep \"$patt\" | xargs bb +sel:", - B("Regex select")" files"}, + "done", B("Regex rename")" files"}, + {{'S'}, + ASK("patt", "Select pattern: ", "")" && bb +sel: $patt", + B("Select")" file(s) by pattern"}, {{'J'}, "+spread:+1", B("Spread")" selection down"}, {{'K'}, "+spread:-1", B("Spread")" selection up"}, {{'b'}, "bb \"+$("ASKECHO("bb +", "")")\"", "Run a "B("bb command")}, {{'s'}, - ("sort=\"$(printf '%s\\n' n s m c a r p | " - PICK("Sort (n)ame (s)ize (m)odification (c)reation (a)ccess (r)andom (p)ermissions: ", "") ")\" " - "&& bb \"+sort:+$sort\" +refresh"), + "sort=\"$(printf '%s\\n' n s m c a r p | " + PICK("Sort (n)ame (s)ize (m)odification (c)reation (a)ccess (r)andom (p)ermissions: ", "") ")\" " + "&& bb \"+sort:+$sort\" +refresh", B("Sort")" by..."}, {{'#'}, "bb \"+col:$("ASKECHO("Set columns: ", "")")\"", "Set "B("columns")}, {{'.'}, "+dotfiles", "Toggle "B("dotfiles")}, |
