Is it possible to not share history between panes/windows in tmux with zsh

tmuxzsh

Until recently I have been using bash with tmux. Bash was behaving as I would expect it to behave, where the history is preserved in each separate pane, and is not shared between panes. However it looks like in zsh the default is for the history in the panes is to be shared. Is there a way to overwrite the default in zsh so that they are not shared when using in tmux?

Best Answer

Tmux should have nothing to do with this, really. So let's focus on your Zsh setup.

You’d have to jump through some hoops to get history to be real-time shared among running Zshs, so it’s surprising that you’re seeing this. What settings have you made to control your Zsh history? Run this to see your settings:

setopt |grep hist

For not saving history immediately, you’ll want:

setopt noincappendhistory
setopt nosharehistory

You can put that into your ~/.zshrc. You may want to log out of running shells to ensure your new settings take place.

For info on all the history-related Zsh options, see man 1 zshoptions and look for the “History” section a few pages in. Note that there are also some environment variables that impact history (SAVEHISTORY, HISTFILE, HISTFILEIGNORE, HISTSIE, HISTFILESIZE).

Related Topic