Controlling bash history
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
- How To Use Bash History Commands and Expansions on a Linux VPS - A great article.
- The Definitive Guide to Bash Command Line History
- Bash History Cheat Sheet
- Preserve bash history in multiple terminal windows
- HISTCONTROL
- Making your BASH history more efficient - HISTCONTROL
- Bash history: “ignoredups” and “erasedups” setting conflict with common history across sessions