Unifying Bash History

A question came up in our Linux User Group IRC channel about the seemingly random mess that is your bash command history. As I googled around for the answer to what was going on I came across this snippet of pure joy.

shopt -s histappend
export PROMPT_COMMAND="history -a; history -n; $PROMPT_COMMAND"

If you add those 2 lines to your .bashrc what you get is a unified bash history. All commands from all terminals get saved in real time and are made available to all other terminals.

It’s pretty great, though it does make you realize that some times you really did rely on the old behavior. The up key no longer does exactly what you are used to.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s