Eternal Bash History

If you want an eternal bash history (including stuff you do in parallel terminals) put this in your .bashrc file:


# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
# Force prompt to write history after every command.
# http://superuser.com/questions/20900/bash-history-loss
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"

To load your existing history do this:

awk '{print; print "#1707340758"}' ~/.bash_history >> ~/.bash_eternal_history

This will add a breaker between each command. The only downside is that all the commands will be listed as having occured in 1970 🙂

Source: https://stackoverflow.com/questions/9457233/unlimited-bash-history