How to preserve Bash history in multiple terminal windows

subject: Shell · date: 2017-12-09

Add the following to ~/.bashrc:

export HISTCONTROL=ignoredups:erasedups  # no duplicate entries
export HISTSIZE=100000                   
export HISTFILESIZE=100000               
shopt -s histappend                      # append to history

# save and reload the history
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"

read more

share this article