There are hell lot of things you can do with your terminal history. For some people its contains more than 50% of knowledge they have and I am one of them. So I decided to manage it in proper way.

Code

#HISTORY
export HISTCONTROL=ignoredups:erasedups  # no duplicate entries
export HISTSIZE=100000                   # big big history
export HISTFILESIZE=1000000               # big big history
shopt -s histappend                      # append to history, don't overwrite it

# Save and reload the history after each command finishes
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"

References

  1. How To Use Bash History Commands and Expansions on a Linux VPS - A great article.
  2. The Definitive Guide to Bash Command Line History
  3. Bash History Cheat Sheet
  4. Preserve bash history in multiple terminal windows
  5. HISTCONTROL
  6. Making your BASH history more efficient - HISTCONTROL
  7. Bash history: “ignoredups” and “erasedups” setting conflict with common history across sessions