Tmux option `xterm-keys` does not enable control+arrows

inputrctmux

I cannot make tmux recognize CtrlLeft-arrow sequence differently from just a left arrow, and the same for the right arrow too. In my ~/.inputrc, I have mapped these sequences (as issued by 2 different terminal emulators, namely putty and mobaxterm) to jump over words in command line:

"\eOD": backward-word
"\e[1;5D": backward-word

This works in an ssh session just fine, but both screen and tmux do not distinguish between arrows and control-arrows. Naturally, the recommended solution is to enable the option xterm-keys in tmux by adding the global option into ~/.tmux.conf, and there is direct evidence (besides the "thanks" comments to the above solution) that this works for other people. But for me, CtrlLeft-arrow sends the same code, ESC D, as does Left-arrow.

I have confirmed that the option is indeed set by checking tmux options with

:show-window-options -g

and even set it just in case for the current window manually with

:set-window-option xterm-keys on

but all this to no avail. tmux reports version number 1.8 with tmux -V.

What else may I check to troubleshoot this problem?

Best Answer

You should use the -g (global) option in this line:

:set-window-option xterm-keys on

making it

:set-window-option -g xterm-keys on

The tmux manual is not very clear, saying of -g:

If -g is specified, the global session or window option is set.
With -a, and if the option expects a string, value is appended to
the existing setting. The -u flag unsets an option, so a session
inherits the option from the global options. It is not possible
to unset a global option.

The key part of this is session, which is the set of pseudo-terminals create when you start tmux.

Related Question