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?

  • How does this differ from the second point in the post you linked?
    – Kevin
    Apr 19, 2012 at 18:01
  • it's not, but none of the solutions I saw seemed to accomplish that point Apr 19, 2012 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, 2012 at 18:40

2 Answers 2


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?


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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