summaryrefslogtreecommitdiff
path: root/client/birdc.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2017-05-17 14:50:00 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-05-17 14:50:00 +0200
commitd19617f06b4526bccc2fc5e5e15c43c754b99a4d (patch)
treecf74bc8e3c56a5d755028c57b02c2baf0c5f0c94 /client/birdc.c
parent144c10fad1ed6a2520abd1c43501ce00ea2699db (diff)
parent31874783c44dd59c355921908016f9b42d22ef02 (diff)
Merge remote-tracking branch 'origin/int-new' into int-new
Diffstat (limited to 'client/birdc.c')
-rw-r--r--client/birdc.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/client/birdc.c b/client/birdc.c
index 8aa01c17..f1aea2fe 100644
--- a/client/birdc.c
+++ b/client/birdc.c
@@ -29,6 +29,9 @@ static int prompt_active;
extern int _rl_vis_botlin;
extern void _rl_move_vert(int);
+#define HISTORY "/.birdc_history"
+static char *history_file;
+
static void
add_history_dedup(char *cmd)
{
@@ -138,8 +141,24 @@ input_help(int arg, int key UNUSED)
}
void
+history_init(void)
+{
+ const char *homedir = getenv("HOME");
+ if (!homedir)
+ homedir = ".";
+ history_file = malloc(strlen(homedir) + sizeof(HISTORY));
+ if (!history_file)
+ die("couldn't alloc enough memory for history file name");
+
+ sprintf(history_file, "%s%s", homedir, HISTORY);
+ read_history(history_file);
+}
+
+void
input_init(void)
{
+ if (interactive)
+ history_init();
rl_readline_name = "birdc";
rl_add_defun("bird-complete", input_complete, '\t');
rl_add_defun("bird-help", input_help, '?');
@@ -217,5 +236,7 @@ cleanup(void)
return;
input_hide();
+ if (interactive)
+ write_history(history_file);
rl_callback_handler_remove();
}