1

I'm trying to run tmux sessions inside and outside of a remote ssh session, so I want to use c-b prefix for the outer (local) session and c-a prefix inner (remote) session.

My question is how can it be done with a single tmux.conf. It's easy to check with bash if the session is remote using something like [ -n "$SSH_CLIENT" ], but I don't know how to reliably incorporate this into tmux.conf, given that if appears to be asynchronous and subject to race conditions.

1 Answer 1

2

I made a workaround via .bash_profile:

if [[ -n "$SSH_CLIENT" && -n "$TMUX" ]] ; then
  tmux unbind c-b
  tmux set -g prefix c-a
  tmux bind c-a send-prefix
fi

It makes sure the c-a prefix is only set if the shell is running in a remote tmux window. Seems to work okay, but it would still be cleaner if it could be expressed in tmux.conf.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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