bash history unleashed

I’m a big fan of set -o vi in bash, and a also of multiple tabbed terminal windows as a way to keep multiple programming/debugging/experimenting contexts active simultaneously.

Nevertheless, it took me almost ten years to take ten minutes to lookup the settings which merge the histories of several terminals in a common file, as opposed to each terminal overwriting the other’s history when exiting.

So here it is, mostly as a note to self:

export HISTSIZE=5000
export HISTCONTROL=ignoredups
shopt -s histappend

/me is happy with his big “treasure chest” history file…

3 Responses to bash history unleashed

  1. Thanks! I didn’t know that.

  2. Greg says:

    And thanks from me. I’ve always been annoyed by the overwriting behaviour.

    If you’re looking for something similar in tcsh, check out this (it doesn’t just apply to OSX):

  3. Lubos Kocman says:

    Following variable PROMPT_COMMAND=”history -a” forces bash to write all to the HISTFILE immediately and not at the end of the session.

    Anyway thanks for ignoredups.

%d bloggers like this: