Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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