Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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've seen this answer:

Preserve bash history in multiple terminal windows

This works for history, but I'm wondering if there is way to extend this so pressing "up" is shared as well?

share|improve this question
How does this differ from the second point in the post you linked? – Kevin Apr 19 '12 at 18:01
it's not, but none of the solutions I saw seemed to accomplish that point – A Question Asker Apr 19 '12 at 18:04
You need to get a new prompt by pressing enter in the second terminal after running the command in the first. – Kevin Apr 19 '12 at 18:40

While bash doesn't have this exact behavior, zsh can do this with

setopt inc_append_history share_history

See How do you share history between terminals in zsh?

share|improve this answer

It should be possible by telling bash to write out and re-read the history after each command. Untested:

PROMPT_COMMAND="$PROMPT_COMMAND"$'\nhistory -a; history -n'

Sharing the history is the default behavior of ksh. In zsh, you get this behavior by turning on the share_history option, and you can get much finer control over how the history is saved and merged by tweaking other history options.

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.