I am running iTerm2 (v 3.2.9) and zsh (v 5.7.1). I normally have 3-4 iTerm tabs opened at the same time and each tab has its own history thanks to the following settings in my .zshrc file

SAVEHIST=10000 # Number of entries

unsetopt inc_append_history
unsetopt share_history
setopt appendhistory

However, when I close and re-open iTerm2 all tabs share the same history (I suppose they are reading from the very same HISTFILE): for example, if I have two tabs (say A and B), where the last command from A is foo and the last command from B is bar, when I close and re-open iTerm2 both tabs see either bar or foo (depending on the latest command which has been run, regardless of A or B) as the last entered command (arrow up key).

My question is: it is possible to keep separate histories even after re-launching iTerm2?

  • This isn't a real answer because I haven't done all the legwork, but it seems possible that you could have those different terminals be launched from different profiles, each with a different zsh command line that specified a different .zshrc file or dotfiles directory. That way those tabs would always come back with the options you prefer. I've searched a bit for this and I'm pretty convinced it could work. I can say for certain that I get a lot of mileage out of multiple iTerm2 profiles for building different local term sessions.
    – Br.Bill
    Aug 29, 2019 at 17:21

1 Answer 1


I don't use iTerm, but I think this is a property of its Session Restoration feature: https://iterm2.com/documentation-restoration.html

Try turning it off and see if it makes any difference.

Besides, starting with macOS Big Sur, you don't even need this feature. macOS now comes with "Resume Support: Save/Restore Shell State", which is by default enabled for both Bash and Zsh, no matter what terminal you use, and which support per-session history. Read the file /etc/zshrc_Apple_Terminal for more info.

You must log in to answer this question.

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