2

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: https://stackoverflow.com/a/9630367

And the explanation here: https://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

1 Answer 1

2

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).

1
  • Fantastic - removing the -n makes this work for me now. Thanks Chris!
    – firebush
    Commented Feb 19, 2013 at 16:00

You must log in to answer this question.

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