commit 44fcb2b1d7b98746c6c81baabf4926997ea67b06
parent 202f65be6972193a310c7b90b1c3602b52f9f569
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date: Mon, 26 Aug 2019 21:35:01 -0700
client: Preserve command history in between the instances
This also limits the number of entries in history to 24.
Diffstat:
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/client/display.c b/client/display.c
@@ -594,10 +594,23 @@ static void signal_handler(void *user_data)
display_refresh_reset();
}
+static char *history_path;
+
void display_init(void)
{
+ const char *home_path;
+
display_refresh.redo_entries = l_queue_new();
+ stifle_history(24);
+
+ home_path = getenv("HOME");
+ if (home_path)
+ history_path = l_strdup_printf("%s/%s", home_path,
+ ".iwctl_history");
+
+ read_history(history_path);
+
setlinebuf(stdout);
resize_signal = l_signal_create(SIGWINCH, signal_handler, NULL, NULL);
@@ -609,6 +622,7 @@ void display_init(void)
rl_erase_empty_line = 1;
rl_callback_handler_install("Waiting for IWD to appear...",
readline_callback);
+
rl_redisplay();
}
@@ -631,5 +645,8 @@ void display_exit(void)
l_signal_remove(resize_signal);
+ write_history(history_path);
+ l_free(history_path);
+
display_quit();
}