How to bind Ctrl-Tab and Ctrl-Shift-Tab in tmux for mintty

1.5k Views Asked by At

I would like to bind CTRL+TAB and CTRL+SHIFT+TAB (without prefix) to tmux functions, under minTTY/cygwin.

I have tried the following tmux configuration:

set-option -gw xterm-keys on
bind-key -n C-Tab next-window
bind-key -n "^[[1;5I" next-window # tmux doesn't recognize
bind-key -n "\e[1;5I" next-window # tmux doesn't recognize

If I hit CTRL+TAB after launching tmux, I get a bell sound. If I hit it after the tmux prefix, it prints 1;5I.

I am using minTTY 2.2.3 under cygwin/Babun. I have disabled minTTY's handling of this key combo via its options (SwitchShortcuts=no in .minttyrc).

For reference, CTRL+TAB and CTRL+SHIFT+TAB work for cycling screen windows with the following .screenrc:

bindkey "^[[1;5I" next
bindkey "^[[1;6I" prev
1

There are 1 best solutions below

1
On

I got here because I bumped into the same issue.

tmux now supports custom key bindings via user-keys - since August 2017, so if you can build tmux yourself, or once a new tmux version is released, it's possible like so:

set -s user-keys[0] "\e[1;5I"
set -s user-keys[1] "\e[1;6I"
bind-key -n User0 select-pane -t+
bind-key -n User1 select-pane -t-

Note that you must use double quotes and not single quotes or else it won't interpret \e correctly.

At the time of writing the example in the manual uses single quotes - https://github.com/tmux/tmux/issues/1043 , though it's likely to be fixed soon.