Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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