Home » Questions » Computers [ Ask a new question ]

Can history files be unified in bash?

Can history files be unified in bash?

I routinely run multiple screen sessions on my Linux desktops and servers.

Asked by: Guest | Views: 310
Total answers/comments: 2
Guest [Entry]

"There are two things you need to do:

Insert the command shopt -s histappend in your .bashrc. This will append to the history file instead of overwriting it.
Also in your .bashrc, insert PROMPT_COMMAND=""$PROMPT_COMMAND;history -a; history -n"" and the history file will be re-written and re-read each time bash shows the prompt.

EDIT: Thanks to e-t172 for the history -n trick"
Guest [Entry]

"None of the solution here worked for me, but what did work was just using:
cat ~/.bash_history | grep something

instead of
history | grep something

Kudos to this SO answer."