28

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?

1 Answer 1

43

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).

2
  • 14
    It is sufficient to ensure that SHARE_HISTORY is not set (setopt nosharehistory). The issue is not that each command is immediately appended to the history file (as with INC_APPEND_HISTORY) but that the commands are also imported from the history file during a shell session (instead only at the beginning), which only happens with SHARE_HISTORY.
    – Adaephon
    Commented Aug 18, 2015 at 7:27
  • 4
    thanks that seemed to solve it for me, I was actually using oh-my-zsh and zsh syntax highlighting. Looks like when you import those things in, "sharehistory" becomes turned on, and disabling it in .zshrc did the right thing. Commented Aug 18, 2015 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.