###### tags: `ubuntu` `bash`
# Why some bash commands is not store in .bash_history
https://unix.stackexchange.com/questions/286300/sometimes-history-commands-are-not-stored-in-bash-history
https://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows/1292#1292
```bash=
# Avoid duplicates
export HISTCONTROL=ignoredups:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend
# After each command, append to the history file and reread it
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
```