From 1f2ee46e39225e2505810d7f958ba8d17628a5f0 Mon Sep 17 00:00:00 2001 From: Martin Dvorak Date: Sun, 15 Dec 2013 14:13:07 +0100 Subject: [PATCH] Removing history flushing (could not work as running in child shell and is shell built-in. --- README.md | 14 ++++++++++---- src/hstr_history.c | 7 ------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 52722fc..0390b32 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,14 @@ https://github.com/dvorka/hstr/releases INSTALLATION ------------ -* bind `hh` to a key and/or add it to $PATH -* bind `hh` to a BASH key by adding a line to your `.bashrc`, e.g. Ctrl-R: +* add + + `shopt -s histappend` + `export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"` + + at the end of `.bashrc` in order to ensure that BASH history of commands + will be kept in sync with filesystem. +* bind `hh` to a BASH key by adding a line to `.bashrc`, e.g. Ctrl-R: `bind '"\C-r": "\C-k\C-uhh\C-j"'` @@ -32,8 +38,8 @@ INSTALLATION To determine the character sequence emitted by a pressed key in terminal, type CTRL-v and then press the key. For example, F12 gives `^[[24~`. - Replace the `^[` with `\e`. To clear the line first, add `\C-k \C-u` in front of - the actual command. Check your current bindings using: + Replace the `^[` with `\e`. To clear the line first, add `\C-k \C-u` in + front of the actual command. Check your current bindings using: `bind -S` diff --git a/src/hstr_history.c b/src/hstr_history.c index cde4a97..1d57aa3 100644 --- a/src/hstr_history.c +++ b/src/hstr_history.c @@ -115,16 +115,9 @@ void free_prioritized_history() { // TODO free(prioritizedHistory); } -void flush_history() { - const char *filename = "history"; - char *const args[1] = {"-a"}; - execvp(filename, args); -} - HistoryItems *get_history_items() { history=(HistoryItems *)malloc(sizeof(HistoryItems)); - flush_history(); using_history(); char *historyFile = getenv(ENV_VAR_HISTFILE);