4

When I SSH in to our server, control + arrow sequences are working fine for me: Ctrl + V then Ctrl + up, down, right, left gives ^[OA, ^[OB, ^[OC, and ^[OD respectively. In tmux, I get ^[[A, ^[[B, ^[[C, and ^[[D.

I'm connecting to Ubuntu via PuTTY, but

  • I have the correct terminal set (putty because ncurses-term is installed). All other key combinations are working in the main shell.
  • I'm using the right character set (UTF-8).
  • I'm definitely getting a 256-colour terminal (I've tried multiple invocations of TERM=... tmux)
  • I've read the tmux FAQs that say to use this config:

    set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@"
    

    making my config like so:

    set -g default-terminal "screen-256color"
    set -g terminal-overrides "screen*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@"
    set-window-option -g xterm-keys on
    

    since screen was recommended elsewhere (though I tried putty there, too.

The only thing I've found that worked is running tput rmkx within tmux, but I don't know if that's the correct solution, what other effects it has, if other programs will change this setting, or even how it should be set correctly in .tmux.conf so that I don't have to type it in manually all the time.


For future readers:

  1. Don't use xterm-keys;
  2. set -g default-terminal "screen-256color" should always be screen or screen-256color because tmux uses the screen terminal type internally; and
  3. set -g terminal-overrides "putty*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@" should always equal/glob-match $TERM outside tmux. By default, PuTTY uses xterm in Connection > Data > Terminal-type, so either use that in the terminal-overrides setting, or change PuTTY to use putty-256color.
3

This is similar to How to enable Control key combinations for GNU screen on putty?, but addresses a different aspect.

In a quick check, it seems that the problem is a conflict between this line

set-window-option -g xterm-keys on

and this:

set -g terminal-overrides "screen*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@"

Dropping the set-window-option makes your configuration work for me.

  • I exited all tmux sessions, commented out the xterm-keys option with a #, a created a new tmux session and no change. – Walf Jun 14 '16 at 0:50
  • Doing the above and using set -g terminal-overrides "putty*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@" worked. (Answer edit to show that correction was rejected.) – Walf Jul 20 '16 at 0:40
0

I now no longer use terminal-overrides nor PuTTY at all. My relevant .tmux.conf is this:

set -g default-terminal "tmux-256color"

I use KiTTY for my terminal emulator, and, where possible, compile a KiTTY-specific terminfo file, otherwise use putty-256color as the terminal type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.