4

When I use multiple terminal sessions at once, bash only persists the commands from one of them. Then later when I try to do a reverse command search, the command I want is not going to come up, because it didn't make it into the history.

I think this is terrible. How can I get a shell history feature that can search back through all my commands, no matter what shell session they were in? I'll gladly switch to a different shell than bash if that is required.

I'm using Mac OS X and Ubuntu.

  • 1
    I never managed to get a properly configured shared history with bash, even with complex hacks that save it at each command. I would suggest to switch to ksh (better the last one, ksh93) with which this is the default configuration. – jlliagre Dec 12 '13 at 2:23
1

The simplest hack would be to add these lines in your .bashrc file:

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

Variations around that technique are shown here.

It might not be reliable in which case you might want to switch to ksh (better the last one, ksh93) with which this is the default configuration.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.