2

when I open terminal session A, type some commands , and then type "history" I see the commands that I was running, but then if I open another terminal session (B) and type "history" I don't see the commands that were typed in to the session A terminal.

how can I sync the history of all terminal sessions in to one file, so when I type "history" from one terminal session I will se the commands from all the sessions?

Artur Meinild
  • 26,018

2 Answers2

1

adding

shopt -s histappend and PROMPT_COMMAND='history -a'

to your .bashrc file should make your terminals append rather than overwrite the .bash_history file.

Then the history command would probably reflect whatever was typed last regardless of terminal.

Regretful
  • 111
1

i found something that works perfectly, added the following line to .bashrc file.

export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"