Add this to your .bashrc file # don't put duplicate lines or lines starting with space in the history, and erase duplicates HISTCONTROL=ignoreboth:erasedups HISTSIZE=5000 HISTFILESIZE=10000 HISTTIMEFORMAT="%Y-%m-%d %H:%M " # append to the history file, don't overwrite it shopt -s histappend With a call to the script logpersistenthistory.sh The scripts use a second history file to save your history accross terminals ph_file="$HOME/.persistent_history" if [ -f ~/bin/log_persistent_history.sh ]; then . ~/bin/log_persistent_history.sh PROMPT_COMMAND="log_persistent_history" else PROMPT_COMMAND= fi