2

I do everything in tmux, so I have a stanza in my .bashrc to create/attach to a session whenever I enter a shell. Sometimes, I ssh into a machine that shares the same configuration. So I'm already in a tmux session on the local machine, and after ssh-ing into the remote, I'm in another tmux session on the remote machine.

I have C-a set as the prefix on both machines, so what winds up happening is that C-a sends the prefix locally, while C-a C-a sends the prefix into the remote machine's tmux session.

I'd like to set two different prefixes for the local and remote sessions (say, ` vs. C-a). But the remote machine is just downstairs, and I may want to walk down there to do something on it directly, in a brand new tmux session, using only the C-a prefix I'm accustomed to. Except since ` was set as a prefix in the ssh tmux session, that now applies to all tmux sessions, and now I have to hit backtick twice to enter it once on the command line.

Is there any way to set separate prefix (or key binding, generally) for different sessions in tmux? Or should I just suck it up and get used to hitting C-a twice?

1 Answer 1

0

In a shell inside tmux (temporary solution):

tmux bind-key -n '`' 'send-keys C-a'

or in your .tmux.conf (permanent config, applied when a new tmux server starts):

bind-key -n '`' 'send-keys C-a'

This binding will make your tmux send C-a upon `. Not to itself though, but to the program running in the current (local) pane (e.g. ssh). Effectively ` will do what your Ctrl+a, Ctrl+a does.

Users with standard tmux config (where C-b is the prefix) should use send-keys C-b.

You must log in to answer this question.

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