]> Sergey Matveev's repositories - nnn.git/commitdiff
Use \ as alternative prompt/run command keybind
authorArun Prakash Jana <engineerarun@gmail.com>
Mon, 9 Dec 2019 19:26:29 +0000 (00:56 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Mon, 9 Dec 2019 19:26:29 +0000 (00:56 +0530)
README.md
src/nnn.c
src/nnn.h

index 2aa8689df5a33a07aeb673af63ef33c62ae0b2d7..e083c90e281b4f5b8ef2369a9c6b1c1ecf5ae8e6 100644 (file)
--- a/README.md
+++ b/README.md
@@ -234,7 +234,7 @@ The list below is from the **dev branch**. Press <kbd>?</kbd> in `nnn` to see th
             C  Execute entry  R ^V  Pick plugin
             U  Manage session    =  Launch app
             c  Remote mount      u  Unmount
-         ] ^P  Prompt/run cmd    L  Lock
+         \ ^P  Prompt/run cmd    L  Lock
 ```
 
 Notes:
index 90463a37be3815c19068320014ed6ff34c9092d0..7a62c0a6108075ac2e9e33bd5f55f11d784a8bdd 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1397,7 +1397,8 @@ static bool xdiraccess(const char *path)
 
 static void opstr(char *buf, char *op)
 {
-       snprintf(buf, CMD_LEN_MAX, "xargs -0 sh -c '%s \"$0\" \"$@\" . < /dev/tty' < %s", op, g_selpath);
+       snprintf(buf, CMD_LEN_MAX, "xargs -0 sh -c '%s \"$0\" \"$@\" . < /dev/tty' < %s",
+                op, g_selpath);
 }
 
 static void rmmulstr(char *buf)
@@ -2073,12 +2074,13 @@ static int filterentries(char *path)
                if (r == OK) {
                        /* Handle all control chars in main loop */
                        if ((*ch < ASCII_MAX && keyname(*ch)[0] == '^' && *ch != '^')
-                           || (*ch == ']' && len == 1)) {
+                           || (*ch == '\\')) {
                                DPRINTF_D(*ch);
                                DPRINTF_S(keyname(*ch));
 
                                /* If there's a filter, try a command on ^P */
-                               if (cfg.filtercmd && *ch == CONTROL('P') && len > 1) {
+                               if (cfg.filtercmd && (*ch == CONTROL('P') || *ch == '\\')
+                                   && len > 1) {
                                        prompt_run(pln, (ndents ? dents[cur].name : ""), path);
 
                                        /* Clear the prompt */
@@ -2086,6 +2088,7 @@ static int filterentries(char *path)
                                                wln[--len] = '\0';
                                        wcstombs(ln, wln, REGEX_MAX);
                                        ndents = total;
+                                       cur = oldcur = 0; /* Ran a command, refresh */
                                        if (matches(pln) != -1)
                                                redraw(path);
 
@@ -2898,10 +2901,14 @@ static void save_session(bool last_session, int *presel)
        for (i = 0; i < CTX_MAX; ++i)
                if ((fwrite(&g_ctx[i].c_cfg, sizeof(settings), 1, fsession) != 1)
                        || (fwrite(&g_ctx[i].color, sizeof(uint), 1, fsession) != 1)
-                       || (header.nameln[i] > 0 && fwrite(g_ctx[i].c_name, header.nameln[i], 1, fsession) != 1)
-                       || (header.lastln[i] > 0 && fwrite(g_ctx[i].c_last, header.lastln[i], 1, fsession) != 1)
-                       || (header.fltrln[i] > 0 && fwrite(g_ctx[i].c_fltr, header.fltrln[i], 1, fsession) != 1)
-                       || (header.pathln[i] > 0 && fwrite(g_ctx[i].c_path, header.pathln[i], 1, fsession) != 1))
+                       || (header.nameln[i] > 0
+                           && fwrite(g_ctx[i].c_name, header.nameln[i], 1, fsession) != 1)
+                       || (header.lastln[i] > 0
+                           && fwrite(g_ctx[i].c_last, header.lastln[i], 1, fsession) != 1)
+                       || (header.fltrln[i] > 0
+                           && fwrite(g_ctx[i].c_fltr, header.fltrln[i], 1, fsession) != 1)
+                       || (header.pathln[i] > 0
+                           && fwrite(g_ctx[i].c_path, header.pathln[i], 1, fsession) != 1))
                        goto END;
 
        status = TRUE;
@@ -2952,10 +2959,14 @@ static bool load_session(const char *sname, char **path, char **lastdir, char **
        for (; i < CTX_MAX; ++i)
                if ((fread(&g_ctx[i].c_cfg, sizeof(settings), 1, fsession) != 1)
                        || (fread(&g_ctx[i].color, sizeof(uint), 1, fsession) != 1)
-                       || (header.nameln[i] > 0 && fread(g_ctx[i].c_name, header.nameln[i], 1, fsession) != 1)
-                       || (header.lastln[i] > 0 && fread(g_ctx[i].c_last, header.lastln[i], 1, fsession) != 1)
-                       || (header.fltrln[i] > 0 && fread(g_ctx[i].c_fltr, header.fltrln[i], 1, fsession) != 1)
-                       || (header.pathln[i] > 0 && fread(g_ctx[i].c_path, header.pathln[i], 1, fsession) != 1))
+                       || (header.nameln[i] > 0
+                           && fread(g_ctx[i].c_name, header.nameln[i], 1, fsession) != 1)
+                       || (header.lastln[i] > 0
+                           && fread(g_ctx[i].c_last, header.lastln[i], 1, fsession) != 1)
+                       || (header.fltrln[i] > 0
+                           && fread(g_ctx[i].c_fltr, header.fltrln[i], 1, fsession) != 1)
+                       || (header.pathln[i] > 0
+                           && fread(g_ctx[i].c_path, header.pathln[i], 1, fsession) != 1))
                        goto END;
 
        *path = g_ctx[cfg.curctx].c_path;
@@ -3507,7 +3518,7 @@ static void show_help(const char *path)
                  "cC  Execute entry  R ^V  Pick plugin\n"
                  "cU  Manage session    =  Launch app\n"
                  "cc  SSHFS mount       u  Unmount\n"
-              "9] ^P  Prompt/run cmd    L  Lock\n"};
+             "9\\ ^P  Prompt/run cmd    L  Lock\n"};
 
        fd = create_tmp_file();
        if (fd == -1)
index 684a0c27b4b41fd0adf62daf2c9409513e422680..577d0682ec5032961fca9cdba815d1579b031c6c 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -257,7 +257,7 @@ static struct key bindings[] = {
        /* Launcher */
        { '=',            SEL_LAUNCH },
        /* Run a command */
-       { ']',            SEL_RUNCMD },
+       { '\\',           SEL_RUNCMD },
        { CONTROL('P'),   SEL_RUNCMD },
        /* Open in EDITOR or PAGER */
        { 'e',            SEL_RUNEDIT },