Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to setup zsh so that it shares command history between different zsh sessions:

  • in multiple tabs
  • in multiple gnome-terminals
  • in different screen sessions

I have put this in .zshrc

#To save every command before it is executed (this is different from bash's history -a solution):
setopt inc_append_history

#To retrieve the history file everytime history is called upon.
setopt share_history

but that does not work.

e.g. I type 1 command: gedit afile and then I go to and zsh and type history. I don't see gedit afile.

output of 'setopt' is

 % setopt
nohistbeep
histexpiredupsfirst
histfindnodups
histignorealldups
histignoredups
histignorespace
histnostore
histreduceblanks
histsavenodups
histverify
incappendhistory
interactive
monitor
promptsubst
sharehistory
shinstdin
zle

How can I achieve this?

share|improve this question
    
What is the output if you run setopt? – simont Dec 15 '12 at 11:45
    
see also similar Q&A superuser.com/questions/446594/… – lumbric Dec 22 '13 at 17:58
up vote 0 down vote accepted

The simple answer to your question is you need to set share_history, you do that with:

setopt share_history

Since you obviously did that already (and that option actually works). I suggest you to check:

  • whether both shells have the option set;
  • whether you are not typing commands with a leading space (since histignorespace makes those be ignored)
  • Do you have $HISTFILE set to the same value in all shells?
  • whether you are actually saving any history? Say, if you issue echo 123 in tab-1. Go to tab-2, call history. Is it there? (as per your problem, not). Now issue, fc -R (means re-read the history file), and then history is it there now? If not, you may also want to call fc -A (-A will forcefully append your history the file) at tab-1 to make sure history is written to the file.
share|improve this answer

try searching after pressing enter.


what i tested was:

  • open 2 zsh shells
  • go to zsh shell 1 and execute echo "something"
  • go to zsh shell 2, press enter, then check if you see the command from shell 1.

in my case i will not see the command until i press enter.

share|improve this answer

You must log in to answer this question.

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