mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Fix #496: option -f to use readline history file
This commit is contained in:
parent
f4786da9bc
commit
0c55977465
|
@ -19,6 +19,7 @@ _nnn ()
|
||||||
-d
|
-d
|
||||||
-e
|
-e
|
||||||
-E
|
-E
|
||||||
|
-f
|
||||||
-g
|
-g
|
||||||
-H
|
-H
|
||||||
-K
|
-K
|
||||||
|
|
|
@ -18,6 +18,7 @@ complete -c nnn -s c -d 'cli-only opener'
|
||||||
complete -c nnn -s d -d 'start in detail mode'
|
complete -c nnn -s d -d 'start in detail mode'
|
||||||
complete -c nnn -s e -d 'open text files in $VISUAL/$EDITOR/vi'
|
complete -c nnn -s e -d 'open text files in $VISUAL/$EDITOR/vi'
|
||||||
complete -c nnn -s E -d 'use EDITOR for undetached edits'
|
complete -c nnn -s E -d 'use EDITOR for undetached edits'
|
||||||
|
complete -c nnn -s f -d 'use readline history file'
|
||||||
complete -c nnn -s g -d 'regex filters'
|
complete -c nnn -s g -d 'regex filters'
|
||||||
complete -c nnn -s H -d 'show hidden files'
|
complete -c nnn -s H -d 'show hidden files'
|
||||||
complete -c nnn -s K -d 'detect key collision'
|
complete -c nnn -s K -d 'detect key collision'
|
||||||
|
|
|
@ -16,6 +16,7 @@ args=(
|
||||||
'(-d)-d[start in detail mode]'
|
'(-d)-d[start in detail mode]'
|
||||||
'(-e)-e[open text files in $VISUAL/$EDITOR/vi]'
|
'(-e)-e[open text files in $VISUAL/$EDITOR/vi]'
|
||||||
'(-E)-E[use EDITOR for undetached edits]'
|
'(-E)-E[use EDITOR for undetached edits]'
|
||||||
|
'(-f)-f[use readline history file]'
|
||||||
'(-g)-g[regex filters]'
|
'(-g)-g[regex filters]'
|
||||||
'(-H)-H[show hidden files]'
|
'(-H)-H[show hidden files]'
|
||||||
'(-K)-K[detect key collision]'
|
'(-K)-K[detect key collision]'
|
||||||
|
|
4
nnn.1
4
nnn.1
|
@ -13,6 +13,7 @@
|
||||||
.Op Ar -d
|
.Op Ar -d
|
||||||
.Op Ar -e
|
.Op Ar -e
|
||||||
.Op Ar -E
|
.Op Ar -E
|
||||||
|
.Op Ar -f
|
||||||
.Op Ar -g
|
.Op Ar -g
|
||||||
.Op Ar -H
|
.Op Ar -H
|
||||||
.Op Ar -K
|
.Op Ar -K
|
||||||
|
@ -73,6 +74,9 @@ supports the following options:
|
||||||
.Fl E
|
.Fl E
|
||||||
use $EDITOR for internal undetached edits
|
use $EDITOR for internal undetached edits
|
||||||
.Pp
|
.Pp
|
||||||
|
.Fl f
|
||||||
|
use readline history file
|
||||||
|
.Pp
|
||||||
.Fl g
|
.Fl g
|
||||||
use regex filters instead of substring match
|
use regex filters instead of substring match
|
||||||
.Pp
|
.Pp
|
||||||
|
|
17
src/nnn.c
17
src/nnn.c
|
@ -6477,6 +6477,9 @@ static void usage(void)
|
||||||
" -d detail mode\n"
|
" -d detail mode\n"
|
||||||
" -e text in $VISUAL ($EDITOR/vi)\n"
|
" -e text in $VISUAL ($EDITOR/vi)\n"
|
||||||
" -E use EDITOR for undetached edits\n"
|
" -E use EDITOR for undetached edits\n"
|
||||||
|
#ifndef NORL
|
||||||
|
" -f use readline history file\n"
|
||||||
|
#endif
|
||||||
" -g regex filters [default: string]\n"
|
" -g regex filters [default: string]\n"
|
||||||
" -H show hidden files\n"
|
" -H show hidden files\n"
|
||||||
" -K detect key collision\n"
|
" -K detect key collision\n"
|
||||||
|
@ -6635,10 +6638,13 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
const char* const env_opts = xgetenv(env_cfg[NNN_OPTS], NULL);
|
const char* const env_opts = xgetenv(env_cfg[NNN_OPTS], NULL);
|
||||||
int env_opts_id = env_opts ? (int)strlen(env_opts) : -1;
|
int env_opts_id = env_opts ? (int)strlen(env_opts) : -1;
|
||||||
|
#ifndef NORL
|
||||||
|
bool rlhist = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
while ((opt = (env_opts_id > 0
|
while ((opt = (env_opts_id > 0
|
||||||
? env_opts[--env_opts_id]
|
? env_opts[--env_opts_id]
|
||||||
: getopt(argc, argv, "aAb:cdeEgHKnop:QrRs:St:T:Vxh"))) != -1) {
|
: getopt(argc, argv, "aAb:cdeEfgHKnop:QrRs:St:T:Vxh"))) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'a':
|
case 'a':
|
||||||
cfg.mtime = 0;
|
cfg.mtime = 0;
|
||||||
|
@ -6666,6 +6672,11 @@ int main(int argc, char *argv[])
|
||||||
case 'E':
|
case 'E':
|
||||||
cfg.waitedit = 1;
|
cfg.waitedit = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
#ifndef NORL
|
||||||
|
rlhist = TRUE;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
cfg.regex = 1;
|
cfg.regex = 1;
|
||||||
filterfn = &visible_re;
|
filterfn = &visible_re;
|
||||||
|
@ -6926,8 +6937,10 @@ int main(int argc, char *argv[])
|
||||||
#else
|
#else
|
||||||
rl_bind_key('\t', rl_complete);
|
rl_bind_key('\t', rl_complete);
|
||||||
#endif
|
#endif
|
||||||
|
if (rlhist) {
|
||||||
mkpath(cfgdir, ".history", g_buf);
|
mkpath(cfgdir, ".history", g_buf);
|
||||||
read_history(g_buf);
|
read_history(g_buf);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NOMOUSE
|
#ifndef NOMOUSE
|
||||||
|
@ -6952,8 +6965,10 @@ int main(int argc, char *argv[])
|
||||||
exitcurses();
|
exitcurses();
|
||||||
|
|
||||||
#ifndef NORL
|
#ifndef NORL
|
||||||
|
if (rlhist) {
|
||||||
mkpath(cfgdir, ".history", g_buf);
|
mkpath(cfgdir, ".history", g_buf);
|
||||||
write_history(g_buf);
|
write_history(g_buf);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cfg.pickraw) {
|
if (cfg.pickraw) {
|
||||||
|
|
Loading…
Reference in a new issue