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

1

6

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
Microdont answered 21/2, 2016 at 8:15 Comment(0)
B
6

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.

Benil answered 19/8, 2017 at 20:8 Comment(1)
This now works with the current release of tmux (2.6) so you no longer have to build it yourself. I had to dig around a bit to get iTerm2 to send the codes in the first place but I guess that is out of the scope of this question.Laszlo

© 2022 - 2024 — McMap. All rights reserved.