You could probably do it with a series of settings, such as (and I haven't fully tested this)...
export PROMPT_COMMAND='history -a; history -c; history -r'
That will cause the most recent command to be appended to your .bash_history
file, then clear your shell history, then re-read the .bash_history
file, each time the shell prompt is printed... so each time you run a command.
So, commands from one terminal will be appended to .bash_history
every time they're run, then the second terminal will pick them up when it re-reads the history file.
Now, keep in mind that this is not realtime, as your second shell will not re-read the history file that was just written by the first shell until a command is run, but it's probably as close as you'll get with bash.
You may find value in setting your HISTCONTROL
envvar to ignoredups
or erasedups
, or this option may not work so well for you.
export HISTCONTROL='erasedups'
zsh
, on the other hand, has it built in. – Thor Jul 26 '12 at 16:59