Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

How can it be achieved so that every command that is entered, is visible in every open terminal's history?

When having multiple terminals open, the history isn't shared, i.e. what you entered in one terminals history, doesn't show up in another one. Think of an alternative to Bash's PROMPT_COMMAND="history -a" (which saves the history before the prompt is beeing displayed).

share|improve this question
See also related and advanced Q&A:… – lumbric Dec 22 '13 at 18:27
up vote 28 down vote accepted

In the .zshrc file, the following values accomplish this:

  • 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

Related for bash:

share|improve this answer
"SHARE_HISTORY: This option both imports new commands from the history file, and also causes your typed commands to be appended to the history file (the latter is like specifying INC_APPEND_HISTORY, which should be turned off if this option is in effect)." (From manual emphasis added) i.e. just the INC_APPEND_HISTORY option will do what you want. – artfulrobot Oct 20 '14 at 10:30

If you can use Robby Russell’s awesome OhMyZSH, it's History plugin will take care of this and more.


That includes setopt inc_append_history.

share|improve this answer

Your Answer


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.