BASH – Bourne Again SHell
BASH is my Unix/Linux shell of choice. It’s a great command line interpreter that strikes the right balance of usefulness and ease of learning. The fact that it’s pre-installed on 100% of computer systems I’m working with today is also a big plus.
BASH History
Shell history is a functionality that allows you to use history command for quickly accessing the commands you typed in the past:
history
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