Skip to content

Commit

Permalink
Add persistent history
Browse files Browse the repository at this point in the history
Closes #10.
  • Loading branch information
yrp604 committed Sep 5, 2018
1 parent d67d363 commit c8aeae9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ void interact(
HistEvent ev;
history(hist, &ev, H_SETSIZE, 100);

char hist_path[PATH_MAX] = { 0 };
snprintf(hist_path, sizeof hist_path, "%s/history", options.rappel_dir);

history(hist, &ev, H_LOAD, hist_path);

el_set(el, EL_HIST, history, hist);

const pid_t child_pid = _gen_child();
Expand Down Expand Up @@ -278,6 +283,14 @@ void interact(

printf("\n");

// we close this one with a file pointer so we can truncate the file
FILE *hist_save = fopen(hist_path, "wb");
REQUIRE (hist_save != NULL);

history(hist, &ev, H_SAVE_FP, hist_save);

REQUIRE (fclose(hist_save) == 0);

history_end(hist);
el_end(el);
}

0 comments on commit c8aeae9

Please sign in to comment.