]> Sergey Matveev's repositories - nnn.git/commitdiff
Option -t replaces NNN_NO_AUTOSELECT
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 16 Aug 2019 18:37:38 +0000 (00:07 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 16 Aug 2019 18:37:38 +0000 (00:07 +0530)
README.md
misc/auto-completion/bash/nnn-completion.bash
misc/auto-completion/fish/nnn.fish
misc/auto-completion/zsh/_nnn
nnn.1
src/nnn.c

index d57d332428971bfbee8882198bb58ed40c865107..4250366aba0b11a9c4c05a6e8ca7c11a475297b8 100644 (file)
--- a/README.md
+++ b/README.md
@@ -224,7 +224,6 @@ Option completion scripts for Bash, Fish and Zsh can be found in respective subd
 | `NNN_OPENER=mimeopen` | custom file opener |
 | `NNN_IDLE_TIMEOUT=300` | idle seconds before locking terminal [default: disabled] |
 | `NNN_COPIER=copier` | clipboard copier script [default: none] |
-| `NNN_NO_AUTOSELECT=1` | do not auto-select matching dir in _nav-as-you-type_ mode |
 | `NNN_TRASH=1` | trash files to the desktop Trash [default: delete] |
 | `NNN_OPS_PROG=1` | show copy, move progress on Linux |
 
@@ -232,7 +231,7 @@ Option completion scripts for Bash, Fish and Zsh can be found in respective subd
 
 ```
 usage: nnn [-b key] [-d] [-e] [-H] [-i] [-n] [-o]
-           [-p file] [-s] [-S] [-v] [-w] [-h] [PATH]
+           [-p file] [-s] [-S] [-t] [-v] [-w] [-h] [PATH]
 
 The missing terminal file manager for X.
 
@@ -250,6 +249,7 @@ optional args:
  -p file selection file (stdout if '-')
  -s      string filters [default: regex]
  -S      du mode
+ -t      disable dir auto-select
  -v      show version
  -w      wild load
  -h      show help
@@ -392,9 +392,7 @@ There is a program option to filter entries by substring match instead of regex.
 
 In this mode directories are opened in filter mode, allowing continuous navigation. Works best with the **arrow keys**.
 
-When there's a unique match and it's a directory, `nnn` auto selects the directory and enters it in this mode. To disable this behaviour,
-
-    export NNN_NO_AUTOSELECT=1
+When there's a unique match and it's a directory, `nnn` auto selects the directory and enters it in this mode. Use the relevant program option to disable this behaviour.
 
 This mode takes navigation to the next level when short, unique keypress sequences are possible. For example, to reach `nnn` development directory (located at `~/GitHub/nnn`) from my `$HOME` (which is the default directory the terminal starts in), I use the sequence <kbd>g</kbd><kbd>n</kbd>.
 
index 35448edde0026304901a67741297b0bc3986ef7d..cb5f12e1dfeea0073191e72b8d00009ba86d7904 100644 (file)
@@ -21,6 +21,7 @@ _nnn () {
         -p
         -s
         -S
+        -t
         -v
         -w
         -h
index c7a7b8b57e47f37e9e1d6903eaa2d706e986d296..a53478f2036f337757abeed817e9a4bea167c935 100644 (file)
@@ -15,6 +15,7 @@ complete -c nnn -s o    -d 'open files only on Enter'
 complete -c nnn -s p -r -d 'copy selection to file'
 complete -c nnn -s s    -d 'use substring match for filters'
 complete -c nnn -s S    -d 'start in disk usage analyzer mode'
+complete -c nnn -s t    -d 'disable dir auto-select'
 complete -c nnn -s v    -d 'show program version and exit'
 complete -c nnn -s w    -d 'wild load'
 complete -c nnn -s h    -d 'show program help'
index 5438b6bd96f9e2b31706e3301ca1a52532f00d22..269bd8f1df05ebd59b5d3e659189221116e386a5 100644 (file)
@@ -19,6 +19,7 @@ args=(
     '(-p)-p[copy selection to file]:file name'
     '(-s)-s[use substring match for filters]'
     '(-S)-S[start in disk usage analyzer mode]'
+    '(-t)-t[disable dir auto-select]'
     '(-v)-v[show program version and exit]'
     '(-w)-w[wild load]'
     '(-h)-h[show program help]'
diff --git a/nnn.1 b/nnn.1
index d08d667c557dbce75be2d3ee0d23a9224ad8cc08..a620d082f22f06fdf66768214a073d80d9fa7c0b 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -67,6 +67,9 @@ supports the following options:
 .Fl S
         start in disk usage analyzer mode
 .Pp
+.Fl t
+        disable directory auto-select in navigate-as-you-type mode
+.Pp
 .Fl v
         show version and exit
 .Pp
@@ -194,11 +197,6 @@ files.
 .Pp
 \fBNNN_COPIER:\fR system clipboard copier script. The project page has some sample copier scripts.
 .Pp
-\fBNNN_NO_AUTOSELECT:\fR disable directory auto-selection in \fInavigate-as-you-type\fR mode.
-.Bd -literal
-    export NNN_NO_AUTOSELECT=1
-.Ed
-.Pp
 \fBNNN_TRASH:\fR trash (instead of \fIdelete\fR) files to desktop Trash.
 .Bd -literal
     export NNN_TRASH=1
index 690f16e9fadc7f5bbf86a2f4130801be709e5ff9..aef492a7b60b7f71e57421a6d5af81da2e69ec8c 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -404,10 +404,9 @@ static const char * const messages[] = {
 #define NNN_NOTE 5
 #define NNNLVL 6 /* strings end here */
 #define NNN_USE_EDITOR 7 /* flags begin here */
-#define NNN_NO_AUTOSELECT 8
-#define NNN_TRASH 9
+#define NNN_TRASH 8
 #ifdef __linux__
-#define NNN_OPS_PROG 10
+#define NNN_OPS_PROG 9
 #endif
 
 static const char * const env_cfg[] = {
@@ -419,7 +418,6 @@ static const char * const env_cfg[] = {
        "NNN_NOTE",
        "NNNLVL",
        "NNN_USE_EDITOR",
-       "NNN_NO_AUTOSELECT",
        "NNN_TRASH",
 #ifdef __linux__
        "NNN_OPS_PROG",
@@ -4575,7 +4573,7 @@ static void usage(void)
 {
        fprintf(stdout,
                "%s: nnn [-b key] [-d] [-e] [-H] [-i] [-n] [-o]\n"
-               "           [-p file] [-s] [-S] [-v] [-w] [-h] [PATH]\n\n"
+               "           [-p file] [-s] [-S] [-t] [-v] [-w] [-h] [PATH]\n\n"
                "The missing terminal file manager for X.\n\n"
                "positional args:\n"
                "  PATH   start dir [default: current dir]\n\n"
@@ -4590,6 +4588,7 @@ static void usage(void)
                " -p file selection file (stdout if '-')\n"
                " -s      string filters [default: regex]\n"
                " -S      du mode\n"
+               " -t      disable dir auto-select\n"
                " -v      show version\n"
                " -w      wild load\n"
                " -h      show help\n\n"
@@ -4722,7 +4721,7 @@ int main(int argc, char *argv[])
        char *arg = NULL;
        int opt;
 
-       while ((opt = getopt(argc, argv, "HSib:denop:svwh")) != -1) {
+       while ((opt = getopt(argc, argv, "HSib:denop:stvwh")) != -1) {
                switch (opt) {
                case 'S':
                        cfg.blkorder = 1;
@@ -4772,6 +4771,9 @@ int main(int argc, char *argv[])
                        cfg.filter_re = 0;
                        filterfn = &visible_str;
                        break;
+               case 't':
+                       cfg.autoselect = 0;
+                       break;
                case 'v':
                        fprintf(stdout, "%s\n", VERSION);
                        return _SUCCESS;
@@ -4934,10 +4936,6 @@ int main(int argc, char *argv[])
        /* Get the clipboard copier, if set */
        copier = getenv(env_cfg[NNN_COPIER]);
 
-       /* Disable auto-select if opted */
-       if (xgetenv_set(env_cfg[NNN_NO_AUTOSELECT]))
-               cfg.autoselect = 0;
-
 #ifdef __linux__
        if (!xgetenv_set(env_cfg[NNN_OPS_PROG])) {
                cp[5] = cp[4];