Add option -s to use string filters

This commit is contained in:
Arun Prakash Jana 2019-02-06 00:38:55 +05:30
parent 512d217392
commit cebb2469d3
No known key found for this signature in database
GPG key ID: A75979F35C080412
6 changed files with 19 additions and 19 deletions

View file

@ -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

12
nnn.1
View file

@ -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

View file

@ -19,6 +19,7 @@ _nnn () {
-l
-n
-p
-s
-S
-v
)

View 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'

View 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'

View file

@ -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);