Snippets are tiny notes I've collected for easy reference.
Append to ~/.bash_history "immediately"
Bash normally waits until a session (terminal) is closed before it writes commands to the history.
You can add a call to history -a
to PROMPT_COMMAND
to make bash to append your history to ~/.bash_history
every time it displays your prompt.
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
The environment variable PROMPT_COMMAND
is executed when bash is about to display your prompt.
The command history -a
appends the current history to ~/.bash_history
.
Snippets are tiny notes I've collected for easy reference.