up vote 2 down vote favorite
share [g+] share [fb]

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?

link|improve this question

80% accept rate
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
feedback

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

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ.

1 Answer

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.

link|improve this answer
feedback

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