Way to preserve terminal tab history across computer restarts

command linehistoryterminal

I'm using Mac 10.9.5. When I run a terminal with multiple tabs (using bash shell), I've noticed that when my computer restarts, the terminal will open up with the same number of tabs that were open in the previous session, but the commands I was running in the previous session (accessible via the "history" shell command) are no longer present in each tab.

Is there a way to preserve each session's history in the appropriate tab between computer restarts?

Best Answer

Try adding this to ~/.bash_profile:

HISTFILE=~/.bash_history.$(basename $(tty))

This creates a unique history file for the terminal associated with each tab.