]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix #496: option -f to use readline history file
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 20 Mar 2020 16:54:15 +0000 (22:24 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 20 Mar 2020 16:54:49 +0000 (22:24 +0530)
misc/auto-completion/bash/nnn-completion.bash
misc/auto-completion/fish/nnn.fish
misc/auto-completion/zsh/_nnn
nnn.1
src/nnn.c

index df37a847855f4af4a8be143e368dca2c710070db..fa5cab3e81ca495afab89b55b03aac650c690893 100644 (file)
@@ -19,6 +19,7 @@ _nnn ()
         -d
         -e
         -E
+        -f
         -g
         -H
         -K
index 5cb31715aa7ee775e6d8594e477e95645efd36e3..3a7f10c9909b4c5f6e084dbce3a30621fc69838a 100644 (file)
@@ -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'
index 2a486bed0545cd5da741595feb2643969657ad30..bdbd555b4d13adeb0a188bde5687052ef48af35c 100644 (file)
@@ -16,6 +16,7 @@ args=(
     '(-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 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -13,6 +13,7 @@
 .Op Ar -d
 .Op Ar -e
 .Op Ar -E
+.Op Ar -f
 .Op Ar -g
 .Op Ar -H
 .Op Ar -K
@@ -73,6 +74,9 @@ supports the following options:
 .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
 .Pp
index 8ca8757c655ca6e35133fb98f8f772296c25383c..c47c0c559538947f6e0547c21dd3cb06ef119c89 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -6477,6 +6477,9 @@ static void usage(void)
                " -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 @@ int main(int argc, char *argv[])
 #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;
@@ -6666,6 +6672,11 @@ int main(int argc, char *argv[])
                case 'E':
                        cfg.waitedit = 1;
                        break;
+               case 'f':
+#ifndef NORL
+                       rlhist = TRUE;
+#endif
+                       break;
                case 'g':
                        cfg.regex = 1;
                        filterfn = &visible_re;
@@ -6926,8 +6937,10 @@ int main(int argc, char *argv[])
 #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 @@ int main(int argc, char *argv[])
        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) {