2

Insert when in xterm, gives ^[[2~ and,

Shift+Insert gives ^[[2;1~

All this is good until I start tmux.

Note that the $TERM variable remains the same, so this issue should not be related to terminfo.

Tmux when in xterm is not able to distinguish between Insert and Shift+Insert and both are read as ^[[2~. Not only xterm, but tmux when started in a virtual console, exhibits the same behaviour.

I tried with and without set -g xterm-keys on in the tmux conf file, but to no avail. FWIW I am running tmux 1.8 on XTerm(296) and these are the overrides in my .Xresources

XTerm*VT100.Translations: #override \
Shift<Key>Insert: string("\033[2;1~") \n\
<Key>Insert: string("\033[2~")

This is really a pain because I want to map Shift+Insert in vim but can't do it in tmux.

Interestingly, when I run GNU screen in the same xterm, it easily distinguishes between Insert and Shift+Insert. I'm starting to believe it's some wickedness in tmux and not my setup.

Does anyone know how to make tmux get the keys transparently just like how xterm gets it without mangling it up in the middle or is there something I am doing wrong?

1
  • The $TERM variable remaining the same does not rule it out. Is is a variant of "screen"? Also, have you tried without a .Xresources?
    – jasonwryan
    Aug 25, 2013 at 18:25

1 Answer 1

0

The value of TERM is irrelevant. As I pointed out in tmux doesn't passes correctly ctrl-shift-arrow sequences, tmux has a table of xterm-style special keys which it knows about. For this case, the table xterm_keys_table has an entry for insert:

    { KEYC_IC,      "\033[2;_~" },

which means that it normally converts any of the variations with a parameter where you see the underscore "_" into the same value:

\033[2;2~
\033[2;3~
\033[2;4~
\033[2;5~
\033[2;6~
\033[2;7~
\033[2;8~

The way to change this is with the xterm-keys setting:

xterm-keys [on | off]
If this option is set, tmux will generate xterm(1)-style function key sequences; these have a number included to indicate modifiers such as Shift, Alt or Ctrl. The default is off.

When you turn the option on, then tmux will pass-through unchanged the special keys that match that pattern:

set-option -gw xterm-keys on

However, you may notice that 1 is not mentioned in the source code for tmux. As tmux reads the keys (before deciding what to do with them), it saves the modifier. It cannot distinguish between a 1 and no modifier at all. That makes sense because xterm would not distinguish the two, either.

In any case, xterm would normally not send anything for a shifted-insert key. You could force it to do this using the translations resource, but according to the xterm manual, a shifted-insert causes it to insert the selected text (i.e., paste):

Shift <KeyPress> Insert:insert-selection(SELECT, CUT_BUFFER0) \n\

You must log in to answer this question.

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