4

I'm a bit of a tmux novice, so there may be a really easy answer to this question, but the title pretty much sums up the question.

Let's say I am ssh'd into a server in a tmux window and I go <prefix>-C. All of a sudden I have to ssh again, which can get annoying. Is there any way to automatically realise that I'm opening up another window from an ssh window already and run that same command in the new window automatically?

1 Answers1

0

I came across your question many months ago and was looking for the same. I finally figured out how to accomplish part of your answer, which is the hardest part (split existing SSH). First install and configure SSHH (SSH Helper) to split the current SSH session into a new pane. Then, we can make it really fast by reusing the same ssh connection by adding this to our SSH config:

ControlMaster                  auto
ControlPath                    /tmp/ssh_mux_%h_%p_%r
ControlPersist                 4h # change to whatever you like, but 4h is a good start. 

Keep in mind that if our connection gets terminated we sometimes have to rm --force /tmp/ssh_mux_*. The tradeoff for superfast SSH splits is worth it!

Also, sshh doesn't work with Fish shell out of the box, but I figured out how to get it working, see https://github.com/yudai/sshh/issues/4.

Elijah Lynn
  • 1,602