]> Sergey Matveev's repositories - nnn.git/commitdiff
Add option -s to use string filters
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 5 Feb 2019 19:08:55 +0000 (00:38 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 5 Feb 2019 19:08:55 +0000 (00:38 +0530)
README.md
nnn.1
scripts/auto-completion/bash/nnn-completion.bash
scripts/auto-completion/fish/nnn.fish
scripts/auto-completion/zsh/_nnn
src/nnn.c

index c0e69d33c1a022667def8eddaacf0c8b1b1e98a6..500c27ced31fa39c003e958a7a423ae10c9a9821 100644 (file)
--- a/README.md
+++ b/README.md
@@ -189,7 +189,7 @@ Search keyword and option completion scripts for Bash, Fish and Zsh can be found
 
 ```
 usage: nnn [-b key] [-C] [-e] [-i] [-l] [-n]
-           [-p file] [-S] [-v] [-h] [PATH]
+           [-p file] [-s] [-S] [-v] [-h] [PATH]
 
 The missing terminal file manager for X.
 
@@ -204,6 +204,7 @@ optional args:
  -l      light mode
  -n      use version compare to sort
  -p file selection file (stdout if '-')
+ -s      string filters [default: regex]
  -S      disk usage mode
  -v      show version
  -h      show help
@@ -320,9 +321,7 @@ Common use cases:
 - type `\.mkv` to list all MKV files
 - use `.*` to match any character (_sort of_ fuzzy search)
 
-To filter entries by substring match:
-
-    export NNN_PLAIN_FILTER=1
+There is a program opton to filter entries by substring match.
 
 If `nnn` is invoked as root or the environment variable `NNN_SHOW_HIDDEN` is set the default filter will also match hidden files.
 
@@ -396,7 +395,6 @@ The option `open with` takes 1 combined argument.
 | `NNN_NO_AUTOSELECT=1` | do not auto-select matching dir in _nav-as-you-type` mode |
 | `NNN_RESTRICT_NAV_OPEN=1` | open files on <kbd> ↵</kbd>, not <kbd>→</kbd> or <kbd>l</kbd> |
 | `NNN_RESTRICT_0B=1` | do not open 0-byte files |
-| `NNN_PLAIN_FILTER=1` | use substring match in filer mode [default: regex] |
 
 #### Help
 
diff --git a/nnn.1 b/nnn.1
index 3640ff904be2d8eb8aeb17346a9292ddd5b1a9b3..acca6694576a73307def960c4d463de4ee2147c1 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -11,7 +11,9 @@
 .Op Ar -e
 .Op Ar -i
 .Op Ar -l
+.Op Ar -n
 .Op Ar -p file
+.Op Ar -s
 .Op Ar -S
 .Op Ar -v
 .Op Ar -h
@@ -187,6 +189,9 @@ supports the following options:
 .Fl "p file"
         copy (or \fIpick\fR) selection to file, or stdout if file='-'
 .Pp
+.Fl s
+        use substring match for filters instead of regex
+.Pp
 .Fl S
         start in disk usage analyzer mode
 .Pp
@@ -235,7 +240,7 @@ with a '^' (caret) symbol.
 .br
 (3) Use '.*' to match any character (\fIsort of\fR fuzzy search).
 .Pp
-To filter entries by substring match export the environment variable \fBNNN_PLAIN_FILTER\fR.
+There is a program option to filter entries by substring match.
 .Pp
 If
 .Nm
@@ -335,11 +340,6 @@ files.
 .Bd -literal
     export NNN_RESTRICT_0B=1
 .Ed
-.Pp
-\fBNNN_PLAIN_FILTER:\fR use substring match in filter mode.
-.Bd -literal
-    export NNN_PLAIN_FILTER=1
-.Ed
 .Sh KNOWN ISSUES
 If you are using urxvt you might have to set backspace key to DEC.
 .Sh AUTHORS
index a83e5d0719c0db49576b443be28f25224427a2f5..095adb99fb92e52efd4df0c0ce3b5fc84c90c075 100644 (file)
@@ -19,6 +19,7 @@ _nnn () {
         -l
         -n
         -p
+        -s
         -S
         -v
     )
index 156e7d4a57d2f751f72262c07708b5c62115e775..3ec36eb5852440f51824ff0c39b661b54289a889 100644 (file)
@@ -13,5 +13,6 @@ complete -c nnn -s i    -d 'start in navigate-as-you-type mode'
 complete -c nnn -s l    -d 'start in light mode (fewer details)'
 complete -c nnn -s n    -d 'use version compare to sort files'
 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 v    -d 'show program version and exit'
index 04670a1ed0ea3ebd6e82874b39ac231cccc7d5ab..9171a913e029f5229d587fa985b2adef2af13bb8 100644 (file)
@@ -17,6 +17,7 @@ args=(
     '(-l)-l[start in light mode (fewer details)]'
     '(-n)-n[use version compare to sort files]'
     '(-p)-p[copy selection to file]:file name'
+    '(-s)-s[use substring match for filters]'
     '(-S)-S[start in disk usage analyzer mode]'
     '(-v)-v[show program version and exit]'
     '*:filename:_files'
index 770ad39942257af08a8b38edb6d4cfb8cf41ea15..7702c01a9e3696ee0ce5932438a798760da8693a 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3956,7 +3956,7 @@ static void usage(void)
 {
        fprintf(stdout,
                "usage: nnn [-b key] [-C] [-e] [-i] [-l] [-n]\n"
-               "           [-p file] [-S] [-v] [-h] [PATH]\n\n"
+               "           [-p file] [-s] [-S] [-v] [-h] [PATH]\n\n"
                "The missing terminal file manager for X.\n\n"
                "positional args:\n"
                "  PATH   start dir [default: current dir]\n\n"
@@ -3968,6 +3968,7 @@ static void usage(void)
                " -l      light mode\n"
                " -n      use version compare to sort\n"
                " -p file selection file (stdout if '-')\n"
+               " -s      string filters [default: regex]\n"
                " -S      disk usage mode\n"
                " -v      show version\n"
                " -h      show help\n\n"
@@ -3980,7 +3981,7 @@ int main(int argc, char *argv[])
        char *ipath = NULL;
        int opt;
 
-       while ((opt = getopt(argc, argv, "Slib:Cenp:vh")) != -1) {
+       while ((opt = getopt(argc, argv, "Slib:Cenp:svh")) != -1) {
                switch (opt) {
                case 'S':
                        cfg.blkorder = 1;
@@ -4019,6 +4020,10 @@ int main(int argc, char *argv[])
                                }
                        }
                        break;
+               case 's':
+                       cfg.filter_re = 0;
+                       filterfn = &visible_str;
+                       break;
                case 'v':
                        fprintf(stdout, "%s\n", VERSION);
                        return 0;
@@ -4168,12 +4173,6 @@ int main(int argc, char *argv[])
        if (getenv(env_cfg[NNN_RESTRICT_0B]))
                cfg.restrict0b = 1;
 
-       /* Use string-comparison in filter mode */
-       if (getenv(env_cfg[NNN_PLAIN_FILTER])) {
-               cfg.filter_re = 0;
-               filterfn = &visible_str;
-       }
-
        /* Ignore certain signals */
        signal(SIGINT, SIG_IGN);
        signal(SIGQUIT, SIG_IGN);