Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Can history files be unified in bash?

I have bash running in an ssh session, call this session A.

I leave the office, go home, ssh to the same box, call this session B.

From session B, I'd like to be able to look at the history of session A.

Is this possible?

share|improve this question

marked as duplicate by Ignacio Vazquez-Abrams, Chris Johnsen, whitequark, Diago Aug 18 '10 at 9:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
I'm not sure if this is possible or not, but this sounds like a good application for screen: gnu.org/software/screen –  Eric Wendelin Aug 18 '10 at 4:14
    
You've closed it anyway, but it's not an exact duplicate. That question wants to be able to set up merged history. I know how to do that. I want to be able to see the history of another shell instance without having initially set up history merging. This leads me to believe it can't be done. –  bstpierre Aug 18 '10 at 11:27

1 Answer 1

There are two issues:

  • appending command to history instead of overwriting it. This can be done by adding this to your .bashrc

    shopt -s histappend

  • rereading the history after each command. This can be done using:

    PROMPT_COMMAND="history -a; history -n"

It is not always as good as it would sound at first sight. Reverse search works great (control-r), but it can be frustrating if you use just "up" from previous command (it will be the last command given in any console).

Maybe there are ways to tweak this... But I think it is a good start for you.

Edit: just seen the comment about duplicate... solution seems exactly the same.

share|improve this answer

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