Shared history in bash

Recent discussion about saving commands and searching commands history made me think about one feature that I miss greatly when I am using bash shell instead of zsh. That is - shared history between shells. I usually have several shell instances open in different windows and workspaces and it’s very convenient to be able to work in them interchangeably having a command you typed in one immediately available to all the others. So, basically what I am looking for is a bash version of zsh’s setopt SHARE_HISTORY to put into my .bashrc.

edit: and setopt INC_APPEND_HISTORY as well I guess.

here there are some options: :slight_smile:

1 Like

Thanks, I will try them out :smiley:

edit: well, got this in my .bashrc

# no duplicates
export HISTCONTROL=ignoredups:erasedups

export HISTSIZE=10000
export HISTFILESIZE=10000

# append to history instead of overwriting it
shopt -s histappend

# save and reload the history after the execution of each command
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"

Still getting some duplicate entries here and there… And history numbering is messed up between the terminals, which is a shame as I am a bang history addict :frowning_face: It’s better than it was before in any case…

1 Like