aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-03-20 22:24:15 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-03-20 22:24:49 +0530
commit0c55977465f1c9aafa50d1131e0570a77d0eeb73 (patch)
treef0ac0085f64a9c318aa5d23b2766abc3d7c2b2e8 /src
parentf4786da9bc012ef7929106b1f22c39730519fd09 (diff)
downloadnnn-0c55977465f1c9aafa50d1131e0570a77d0eeb73.tar.gz
Fix #496: option -f to use readline history file
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 8ca8757..c47c0c5 100644
--- 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) {