Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My goal is to use C-k as my tmux prefix on my local machine, but when I'm on a tmux session that itself contains an ssh session into a machine that is hosting a tmux session, I'd like to press C-kj (or C-k C-j, or whatever) to get the prefix across to the remote tmux session.

Per the .tmux.conf linked to from here: http://stackoverflow.com/a/9630367

And the explanation here: http://stackoverflow.com/a/8530024

I've set the following:

# prefix and send-prefix settings.
unbind C-b
set -g prefix C-k
bind-key -n C-j send-prefix

It seems so simple, but somehow the above isn't working for me. C-k works great on single tmux sessions, but C-k C-j doesn't get through the prefix to the remote one. I'm clearly missing something simple.

local tmux is on Ubuntu and is version 1.6

Remote tmux is usually on RedHat and is version 1.6.

Note: Without any of these settings, C-b C-b sends the prefix to the remote machine as expected. But I'd really prefer C-k and C-k C-j.

My entire config (for both the local and remote machines):

# prefix and send-prefix settings.
unbind C-b
set -g prefix C-k
bind-key -n C-j send-prefix

# Set scrollback buffer n lines.
set -g history-limit 5000

# Listen for activity on all windows.
set -g bell-action any

set -g status-bg blue
set -g status-fg white
set -g status-left '#[fg=yellow]#H'
set-window-option -g window-status-current-bg magenta

# Set vi mode bindings.
setw -g mode-keys vi
share|improve this question

1 Answer 1

up vote 2 down vote accepted

If you want to use C-k C-j to send a C-k to the inner session (i.e. send a prefix to the tmux running on the other side of the the ssh session), then you probably want to omit the -n option when binding C-j.

# prefix and send-prefix settings.
unbind C-b
set -g prefix C-k
bind-key C-j send-prefix

With the above configuration (in both tmux instances), you can type (e.g.) C-k C-j c to create a new window in the nested session.


I described using a -n binding in the second answer that you linked because it lets you use a single key as if it were simply the prefix in the nested session. For example, with -n (the configuration as you described it in your question), you could type C-j c to create a new window in the nested session. If you do not mind having to type the prefix, then a non--n binding is probably better since -n bindings can be quite intrusive (they make it difficult to use the -n-bound key with stuff running in tmux-controlled ttys).

share|improve this answer
    
Fantastic - removing the -n makes this work for me now. Thanks Chris! –  firebush Feb 19 '13 at 16:00

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.