README.md | 8 +++----- nnn.1 | 12 ++++++------ scripts/auto-completion/bash/nnn-completion.bash | 1 + scripts/auto-completion/fish/nnn.fish | 1 + scripts/auto-completion/zsh/_nnn | 1 + src/nnn.c | 15 +++++++-------- diff --git a/README.md b/README.md index c0e69d33c1a022667def8eddaacf0c8b1b1e98a6..500c27ced31fa39c003e958a7a423ae10c9a9821 100644 --- a/README.md +++ b/README.md @@ -189,7 +189,7 @@ #### Cmdline options ``` 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 @@ -i nav-as-you-type mode -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 @@ - to list all matches starting with the filter expression, start the expression with a `^` (caret) symbol - 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 @@ | `NNN_SHOW_HIDDEN=1` | show hidden (.) files [default: do not show hidden if not root ] | | `NNN_NO_AUTOSELECT=1` | do not auto-select matching dir in _nav-as-you-type` mode | | `NNN_RESTRICT_NAV_OPEN=1` | open files on , not or l | | `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 --- a/nnn.1 +++ b/nnn.1 @@ -11,7 +11,9 @@ .Op Ar -C .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 @@ .Pp .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 @@ (2) Type '\\.mkv' to list all MKV files. .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 @@ -334,11 +339,6 @@ .Pp \fBNNN_RESTRICT_0B:\fR restrict opening 0-byte files due to unexpected behaviour; use \fIedit\fR or \fIopen with\fR to open the file. .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. diff --git a/scripts/auto-completion/bash/nnn-completion.bash b/scripts/auto-completion/bash/nnn-completion.bash index a83e5d0719c0db49576b443be28f25224427a2f5..095adb99fb92e52efd4df0c0ce3b5fc84c90c075 100644 --- a/scripts/auto-completion/bash/nnn-completion.bash +++ b/scripts/auto-completion/bash/nnn-completion.bash @@ -19,6 +19,7 @@ -i -l -n -p + -s -S -v ) diff --git a/scripts/auto-completion/fish/nnn.fish b/scripts/auto-completion/fish/nnn.fish index 156e7d4a57d2f751f72262c07708b5c62115e775..3ec36eb5852440f51824ff0c39b661b54289a889 100644 --- a/scripts/auto-completion/fish/nnn.fish +++ b/scripts/auto-completion/fish/nnn.fish @@ -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' diff --git a/scripts/auto-completion/zsh/_nnn b/scripts/auto-completion/zsh/_nnn index 04670a1ed0ea3ebd6e82874b39ac231cccc7d5ab..9171a913e029f5229d587fa985b2adef2af13bb8 100644 --- a/scripts/auto-completion/zsh/_nnn +++ b/scripts/auto-completion/zsh/_nnn @@ -17,6 +17,7 @@ '(-i)-i[start in navigate-as-you-type mode]' '(-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' diff --git a/src/nnn.c b/src/nnn.c index 770ad39942257af08a8b38edb6d4cfb8cf41ea15..7702c01a9e3696ee0ce5932438a798760da8693a 100644 --- 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 @@ " -i nav-as-you-type mode\n" " -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 @@ char cwd[PATH_MAX] __attribute__ ((aligned)); 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; @@ -4018,6 +4019,10 @@ fprintf(stderr, "%s\n", strerror(errno)); return 1; } } + break; + case 's': + cfg.filter_re = 0; + filterfn = &visible_str; break; case 'v': fprintf(stdout, "%s\n", VERSION); @@ -4167,12 +4172,6 @@ /* Restrict opening of 0-byte files */ 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);