misc/auto-completion/bash/nnn-completion.bash | 1 + misc/auto-completion/fish/nnn.fish | 1 + misc/auto-completion/zsh/_nnn | 1 + nnn.1 | 4 ++++ src/nnn.c | 25 ++++++++++++++++++++----- diff --git a/misc/auto-completion/bash/nnn-completion.bash b/misc/auto-completion/bash/nnn-completion.bash index df37a847855f4af4a8be143e368dca2c710070db..fa5cab3e81ca495afab89b55b03aac650c690893 100644 --- a/misc/auto-completion/bash/nnn-completion.bash +++ b/misc/auto-completion/bash/nnn-completion.bash @@ -19,6 +19,7 @@ -c -d -e -E + -f -g -H -K diff --git a/misc/auto-completion/fish/nnn.fish b/misc/auto-completion/fish/nnn.fish index 5cb31715aa7ee775e6d8594e477e95645efd36e3..3a7f10c9909b4c5f6e084dbce3a30621fc69838a 100644 --- a/misc/auto-completion/fish/nnn.fish +++ b/misc/auto-completion/fish/nnn.fish @@ -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 e -d 'open text files in $VISUAL/$EDITOR/vi' 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 H -d 'show hidden files' complete -c nnn -s K -d 'detect key collision' diff --git a/misc/auto-completion/zsh/_nnn b/misc/auto-completion/zsh/_nnn index 2a486bed0545cd5da741595feb2643969657ad30..bdbd555b4d13adeb0a188bde5687052ef48af35c 100644 --- a/misc/auto-completion/zsh/_nnn +++ b/misc/auto-completion/zsh/_nnn @@ -16,6 +16,7 @@ '(-c)-c[cli-only opener]' '(-d)-d[start in detail mode]' '(-e)-e[open text files in $VISUAL/$EDITOR/vi]' '(-E)-E[use EDITOR for undetached edits]' + '(-f)-f[use readline history file]' '(-g)-g[regex filters]' '(-H)-H[show hidden files]' '(-K)-K[detect key collision]' diff --git a/nnn.1 b/nnn.1 index f843d7a070abd394b87dde653445b628550b79c8..84b184cb5e89a31ce862d09ec8da1e0778c379ce 100644 --- a/nnn.1 +++ b/nnn.1 @@ -13,6 +13,7 @@ .Op Ar -c .Op Ar -d .Op Ar -e .Op Ar -E +.Op Ar -f .Op Ar -g .Op Ar -H .Op Ar -K @@ -72,6 +73,9 @@ open text files in $VISUAL (else $EDITOR, fallback vi) [preferably CLI] .Pp .Fl E use $EDITOR for internal undetached edits +.Pp +.Fl f + use readline history file .Pp .Fl g use regex filters instead of substring match diff --git a/src/nnn.c b/src/nnn.c index 8ca8757c655ca6e35133fb98f8f772296c25383c..c47c0c559538947f6e0547c21dd3cb06ef119c89 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -6477,6 +6477,9 @@ " -c cli-only opener (overrides -e)\n" " -d detail mode\n" " -e text in $VISUAL ($EDITOR/vi)\n" " -E use EDITOR for undetached edits\n" +#ifndef NORL + " -f use readline history file\n" +#endif " -g regex filters [default: string]\n" " -H show hidden files\n" " -K detect key collision\n" @@ -6635,10 +6638,13 @@ middle_click_key = middle_click_env[0]; #endif const char* const env_opts = xgetenv(env_cfg[NNN_OPTS], NULL); int env_opts_id = env_opts ? (int)strlen(env_opts) : -1; +#ifndef NORL + bool rlhist = FALSE; +#endif while ((opt = (env_opts_id > 0 ? 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) { case 'a': cfg.mtime = 0; @@ -6665,6 +6671,11 @@ cfg.useeditor = 1; break; case 'E': cfg.waitedit = 1; + break; + case 'f': +#ifndef NORL + rlhist = TRUE; +#endif break; case 'g': cfg.regex = 1; @@ -6926,8 +6937,10 @@ rl_bind_key('\t', rl_menu_complete); #else rl_bind_key('\t', rl_complete); #endif - mkpath(cfgdir, ".history", g_buf); - read_history(g_buf); + if (rlhist) { + mkpath(cfgdir, ".history", g_buf); + read_history(g_buf); + } #endif #ifndef NOMOUSE @@ -6952,8 +6965,10 @@ exitcurses(); #ifndef NORL - mkpath(cfgdir, ".history", g_buf); - write_history(g_buf); + if (rlhist) { + mkpath(cfgdir, ".history", g_buf); + write_history(g_buf); + } #endif if (cfg.pickraw) {