Skip to main content
Post Merged (destination) from unix.stackexchange.com/questions/25334/…
added two other history commands since he says he wants to use it in other running sessions
Source Link
Chris Down
  • 130.3k
  • 26
  • 277
  • 268

To do this, you'll need to add two lines to your ~/.bashrc:

shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"a;history -c;history -r;$PROMPT_COMMAND"

From man bash:

If the histappend shell option is enabled (see the description of shopt under SHELL BUILTIN COMMANDS below), the lines are appended to the history file, otherwise the history file is over-written.

To do this, you'll need to add two lines to your ~/.bashrc:

shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"

From man bash:

If the histappend shell option is enabled (see the description of shopt under SHELL BUILTIN COMMANDS below), the lines are appended to the history file, otherwise the history file is over-written.

To do this, you'll need to add two lines to your ~/.bashrc:

shopt -s histappend
PROMPT_COMMAND="history -a;history -c;history -r;$PROMPT_COMMAND"

From man bash:

If the histappend shell option is enabled (see the description of shopt under SHELL BUILTIN COMMANDS below), the lines are appended to the history file, otherwise the history file is over-written.

Source Link
Chris Down
  • 130.3k
  • 26
  • 277
  • 268

To do this, you'll need to add two lines to your ~/.bashrc:

shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"

From man bash:

If the histappend shell option is enabled (see the description of shopt under SHELL BUILTIN COMMANDS below), the lines are appended to the history file, otherwise the history file is over-written.