27

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?

Community
  • 1
  • 1
Hristo Asenov
  • 439
  • 1
  • 4
  • 8

1 Answers1

39

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

Micah Elliott
  • 9,600
  • 5
  • 51
  • 54
  • 12
    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 Aug 18 '15 at 07:27
  • 3
    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. – Hristo Asenov Aug 18 '15 at 15:54