For every Unix user, there comes a point where shell history suddenly becomes very relevant. You learn to consult it, then start recovering the last command, then switch to searching past commands history to save precious time normaly taken typing.
Shortly after such a point in your life, you'll probably want to enhance your shell history in two very common ways:
- Make sure every terminal window can update AND access your centralized shell history. So you run a command or two in one window, then type "history" anywhere else and see them two commands right there.
- Provide meanigful timeline, this is done with timestamps. Very simple and powerful change helps you see exactly when each command occured.
Here's how you achieve both of these massive improvents to your history in BASH. Just add this to /etc/bashrc on your Linux system:
export
HISTTIMEFORMAT=
"%d.%m.%y %T "
export
HISTCONTROL=ignoredups:erasedups
shopt
-s histappend
export
PROMPT_COMMAND=
"${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r;"
export
HISTCONTROL=ignoreboth