Adams Bros Blog


Save Bash History Realtime

I kind of get sick of my work computer dying, and then I lose some history because I forgot to exit my terminal sessions.  I've always used the histappend feature, but this prompt command thing is great. 😀  Thank you Stack Exchange.  The other benefit of this is that each terminal immediately receives the new history next time you press enter.

shopt -s histappend # append to history, don't overwrite it
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
Filed under: Bash Leave a comment
Comments (1) Trackbacks (0)
  1. I was just thinking the same thing this week. Strangely good timing!

Leave a comment


No trackbacks yet.