I would like to use my ssh tmux session inside my development tmux session, but it makes tmux behave bad (keys go to wrong session, etc). Is there a way to do it properly?
To detach (meaning exit the window to come back to later) from the tmux session, use CTRL + b then d (hold ctrl, press b, let go of both of the keys, and press d). Whatever program(s) you are running in the tmux session will continue going without you.
To enter Command mode, press Prefix : (the colon) from within a running tmux session. The status bar changes color and we get a command prompt that indicates that we can type our command.
With tmux you only need one SSH connection to the server. The great thing about tmux is it allows you to have multiple panes open at the same time, each with their own shell running, but using the same, single SSH connection.
You can set up
bind-key b send-prefix
in your .tmux.conf
. By default all commands go to the outermost tmux session. If you press <prefix-key>
b (<prefix-key>
=ctrlb by default) the commands go to the inner session. Here an example:
ctrl-b c # create new window in the outer session
ctrl-b b c # create new window in the inner session
ctrl-b % # create split window in the outer session
ctrl-b b % # create split window in the inner session
At least on my machines, I need to press "the key" (prefix-key) twice, to get a command to the tmux inside the base tmux,
So if I from a tmux window, I ssh into a server and attach to a tmux session as @Marco described above, I need to do these:
ctrl-b-b c # create a new window on the server (remote tmux)
ctrl-b c # create a new window on my desktop (local tmux)
to make is super clear, ctrl-b-b
means hold down ctrl
press b
twice then release and press the command key, c
in the example above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With