0

shopt -s histappend will append to history without ever wiping it out

history -a will update your history immediately.

history -n will read from history file when run instead of just at start of terminal.

So, add the shopt -s histappend to your .bash_profile or .bashrc and then set your PROMPT_COMMAND with the history commands like so:

export PROMPT_COMMAND="history -a; history -n"

12 earlier thoughts