Terminal gets bash to go through an elaborate dance to keep separate histories for each tab. Normally (for me anyway) after a restart of Mac OS these separate histories are lost and you are left with just one.

At one time (years ago) the separate histories survived a reboot (much to my delight) but after yet another OS upgrade it went back to the old behavior.

Over the intervening period I have done sporadic searches trying to find out if I imagined this and what the expected behaviour is but turned up nothing useful.

So, was I imagining this and if not how do I get terminal to preserve individual histories between reboots/logouts?

There is this post which I think addresses the same issue but the answer is bit cryptic for me and it isn't clear where you should add the trap command. Although it may explain why the behaviour comes and goes if that trap is at the in /etc/bashrc_Apple_Terminal and then another OS release comes along without it!

  • It appears the answer you linked to is relevant to your issue. The only line in /etc/bashrc_Apple_Terminal that contains a trap is the very last line: trap shell_session_update EXIT. The answer implies substituting HUP for EXIT may have helped, but as you've noted, it may be version-dependent. There's also a suggestion in that Q&A that how Terminal is terminated (exit vs. Command-Q) is relevant. Changing EXIT to HUP is worth a try IMHO (easy & easily restored) - see what happens.
    – Seamus
    Commented May 22, 2019 at 22:55
  • help history; you could try setting a different HISTFILE=/Users/mac/.bash_history; for each tab. No idea how you would coordinate these. Commented May 23, 2019 at 0:37

1 Answer 1


The answer is simple and obvious — i just never thought of it until I did it by accident.

You need to shut down the shell in each tab before you exit terminal. Then when you restart the histories get restored as expected. Shutting down bash causes it to execute the hooks that save the history properly

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .