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?

  • I'm not sure if this is possible or not, but this sounds like a good application for screen: gnu.org/software/screen Aug 18, 2010 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, 2010 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.

Not the answer you're looking for? Browse other questions tagged .