]> Sergey Matveev's repositories - nnn.git/commitdiff
Key N to switch to context N
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 19 Jan 2019 07:39:46 +0000 (13:09 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 19 Jan 2019 07:39:46 +0000 (13:09 +0530)
README.md
nnn.1
src/nnn.c
src/nnn.h

index e9148c24952c0f0ffb304039900f4070696841df..189acd19934c2a6e97c23fc119a1b235ed57e092 100644 (file)
--- a/README.md
+++ b/README.md
@@ -216,7 +216,7 @@ Press <kbd>?</kbd> in `nnn` to see the list anytime.
               /  Filter        Ins, ^T  Toggle nav-as-you-type
               b  Pin current dir    ^W  Go to pinned dir
         Tab, ^I  Next context        d  Toggle detail view
-          `, ^/  Leader key    LeaderN  Go to/create context N
+          `, ^/  Leader key   N, LeadN  Go to/create context N
             Esc  Exit prompt        ^L  Redraw/clear prompt
              ^G  Quit and cd         q  Quit context
           Q, ^Q  Quit                ?  Help, config
diff --git a/nnn.1 b/nnn.1
index 92f4ef234d7e945b67979392e080b462d58692df..f97bc97a96212ae71abaa0a72aeddcd75ad2558d 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -67,7 +67,7 @@ Toggle detail view
 Next context, ask to create if none
 .It Ic `, ^/
 Leader key
-.It Ic LeaderN
+.It Ic N, LeaderN
 Switch to context N
 .It Ic Esc
 Exit prompt
index 5062f160b6bd52dca911b02b70428a2990f1ef76..7130d3301e3c89d890a245ead18891b92afc7584 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2100,7 +2100,7 @@ static bool show_help(char *path)
              "e/  Filter        Ins, ^T  Toggle nav-as-you-type\n"
              "eb  Pin current dir    ^W  Go to pinned dir\n"
        "8Tab, ^I  Next context        d  Toggle detail view\n"
-         "a`, ^/  Leader key    LeaderN  Go to/create context N\n"
+         "a`, ^/  Leader key   N, LeadN  Go to/create context N\n"
            "cEsc  Exit prompt        ^L  Redraw/clear prompt\n"
             "d^G  Quit and cd         q  Quit context\n"
          "aQ, ^Q  Quit                ?  Help, config\n"
@@ -2874,9 +2874,15 @@ nochange:
                        setdirwatch();
                        goto begin;
                case SEL_LEADER: // fallthrough
-               case SEL_CYCLE:
+               case SEL_CYCLE: // fallthrough
+               case SEL_CTX1: // fallthrough
+               case SEL_CTX2: // fallthrough
+               case SEL_CTX3: // fallthrough
+               case SEL_CTX4:
                        if (sel == SEL_CYCLE)
                                fd = '>';
+                       else if (sel >= SEL_CTX1 && sel <= SEL_CTX4)
+                               fd = sel - SEL_CTX1 + '1';
                        else
                                fd = get_input(NULL);
 
@@ -2887,9 +2893,9 @@ nochange:
                        case '&':
                                presel = fd;
                                goto nochange;
-                       case '>':
-                       case '.':
-                       case '<':
+                       case '>': // fallthrough
+                       case '.': // fallthrough
+                       case '<': // fallthrough
                        case ',':
                                r = cfg.curctx;
                                if (fd == '>' || fd == '.')
index 71f5c3edec880d31d8510a92f064965740a31018..ec9c2c1cb7e3733d6428cf813857197161c29fd9 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -50,6 +50,10 @@ enum action {
        SEL_CDLAST,
        SEL_LEADER,
        SEL_CYCLE,
+       SEL_CTX1,
+       SEL_CTX2,
+       SEL_CTX3,
+       SEL_CTX4,
        SEL_PIN,
        SEL_VISIT,
        SEL_FLTR,
@@ -145,6 +149,11 @@ static struct key bindings[] = {
        /* Cycle contexts in forward direction */
        { '\t',           SEL_CYCLE },
        { CONTROL('I'),   SEL_CYCLE },
+       /* Go to/create context N */
+       { '1',            SEL_CTX1 },
+       { '2',            SEL_CTX2 },
+       { '3',            SEL_CTX3 },
+       { '4',            SEL_CTX4 },
        /* Mark a path to visit later */
        { 'b',            SEL_PIN },
        /* Visit marked directory */