9

I cannot make tmux recognize Ctrl-Left-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, Ctrl-Left-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?

1 Answer 1

5

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

for tmux 1.8. However, tmux 3.3 enables this feature by default (changed May 2020, released June 2022):

commit 5ee4d991b6a325848083017665ac3d3ace2d1fa1                                 
Author: Nicholas Marriott <[email protected]>                         
Date:   Fri May 15 10:31:54 2020 +0100

    xterm-keys has been on by default for 5 years and all other modern terminals
    use these key sequences by default. Merge the code into the main tty and input
    tree processing (convering the latter to use a tree rather than a table at the
    same time) and make the option a no-op.

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.

2

You must log in to answer this question.

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