I'm trying to a get a ctrl+tab and ctrl+shift+tab binding to work inside of a tmux session (I'm also using PuTTY).

I already went through the pains of having to recompile PuTTY so it would send ctrl and shift correctly. After using ctrl+v, and I'm able to see that ^[[27;5;9~ and ^[[27;6;9~ are being sent for ctrl+tab and ctrl+shift+tab, respectively. Is there any way I can get these bound to next-window and previous-window inside of tmux?

Edit: After some research, I'm thinking I might have to configure xterm to include those keycodes. Any idea how I would go about doing that?

Edit2: So I found out I can retrieve infocmp and recompile it. I added

kctab=\E[27;5;9~, kcstab=\E[27;6;9~,

to the end of it, except now it's giving me an error. "entry does not start with terminal names in column one"

share|improve this question
    
Instructions for how to recompile PuTTY with Ctrl-Tab support. scnr.net/blog/index.php/archives/61 – Christian Long Mar 23 '15 at 17:06
    
Thank you for your question. – CodyChan Apr 23 '15 at 7:59
up vote 34 down vote accepted

Recent “unreleased” versions of tmux do automatically recognize those xterm-style key sequences once you have your terminal sending them (no need to change your terminfo entry). The next release version (1.8?) should also have this support. With an appropriate build of tmux1, all you have to do is bind the keys in your tmux configuration:

bind-key C-Tab next-window
bind-key C-S-Tab previous-window

You will still need to type your prefix key before these keys.

(Note: ~/.tmux.conf is only processed when the server starts. If you make changes to it, you will either need to exit all your sessions and restart the server, or use (e.g.) tmux source ~/.tmux.conf to have your existing server re-process the file.)

Also, if you want tmux to pass along these (and other) xterm-style key sequences to programs running inside tmux, then you will need to enable the xterm-keys window option.

set-option -gw xterm-keys on

(If you prefer, you can do this on a per-window basis by using -w instead of -gw.)


If you want to be able to use those keys without typing the prefix, then you can use “no prefix” bindings instead:

bind-key -n C-Tab next-window
bind-key -n C-S-Tab previous-window

This will more or less “dedicate” the keys to tmux, though. It will be difficult to type these keys to any program running inside tmux (e.g. you would have to use the tmux command send-keys C-Tab—as normal, xterm-keys must be enabled to send these xterm-style key sequences).


The problem with your terminfo entry editing is probably because each line after the one that names the terminal type needs to start with a Tab. Lines that do not start with a tab are the beginning of a new terminal entry. Technically, the NL TAB sequence is basically a line continuation in this file format; each entry is a single logical line.

Also, if you are redefining terminfo entries, be sure to use -x with infocmp and tic to preserve the user-defined capabilities (some of which are fairly standard).


1 I.e. built from recent code in the tmux Git repository at sf.net (at the clone-able URL git://git.code.sf.net/p/tmux/tmux-code).

share|improve this answer
    
tmux doesn't recognize C-Tab and C-S-Tab as valid keys (says it is an unknown key).And thanks for the heads up, I reverted my terminfo changes because to be honest, I didn't really know what I was doing. – dook Mar 19 '13 at 5:17
    
Oops, C-Tab (and C-S-Tab) are recognized in my build of tmux, but that feature is not part of the latest release (1.7). If you build a recent version of the not-yet-released code (i.e. from git://git.code.sf.net/p/tmux/tmux-code), then it will support these keys. Sorry about the confusion! I will update the answer text to describe this situation. – Chris Johnsen Mar 19 '13 at 6:29
    
Oh thank you chris! I'll let you know once I get it recompiled and installed – dook Mar 19 '13 at 6:57
4  
as a note, you can reload tmux config on the fly. :source-file ~/.tmux.conf if in tmux, or you can bind it. – damianb Feb 8 '14 at 23:11
6  
another note for fast reloading bind r source-file ~/.tmux.conf \; display "Reloaded!" so I reload the settings with a prefix + Ctrl-r – Mahmoud.Mahfouz Dec 4 '15 at 16:45

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.