3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 04:32:37 +01:00

client: Preserve command history in between the instances

This also limits the number of entries in history to 24.
This commit is contained in:
Tim Kourt 2019-08-26 21:35:01 -07:00 committed by Denis Kenzior
parent 202f65be69
commit 44fcb2b1d7

View File

@ -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();
}