3

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?

2 Answers2

1

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?

bahamat
  • 39,666
  • 4
  • 75
  • 104
0

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.