Ubuntu 12.10, TERM is set to screen-256color in putty and tmux.conf, confirmed when I export both in and out of a tmux session.

If I run cat > /dev/null and then press <down> then <c-down>, I get ^[[B^[OB outside of a tmux session, but ^[[B^[[B while inside a session.

I've tried setw -g xterm-keys on in my .tmux.conf to no avail.


screen-256color is a valid TERM value for use inside tmux, but xterm-256color would probably be more appropriate for outside of tmux (where you are “just inside” PuTTY). Attaching to a tmux session with an inaccurate TERM value is akin to lying to tmux about the control sequences your terminal emulator uses (i.e. PuTTY probably does not support exactly the control sequences described by the screen-256color terminfo database entry).

I do not use PuTTY, but searching around a bit left me with the impression that PuTTY does not support sending sequences that actually mean (e.g.) Control+Down Arrow. The different sequences you observe are actually two different sequences for plain Down Arrow. ^[[B is the normal sequence, and ^[OB is for when a program has requested “application cursor keys” mode.

So, when PuTTY sends ^[OB, any program expecting xterm-style sequences will interpret that sequence as “Down Arrow, while in application cursor keys mode” (or just Down Arrow), but never as Control+Down Arrow. Specifically, when tmux sees either of those sequences, it interprets it as a plain Down Arrow. The sequence that tmux then generates for its pane depends on whether that particular pane has been configured for application cursor key mode or not.

In your case, you have not asked tmux to switch its pane to application cursor keys mode, so it translated the sequence to its “normal” sequence in both cases. You should be able to observe the difference by running commands like these (either inside or outside a tmux) (the tput commands generate the control sequences that activate and deactivate the required terminal modes):

# Activate "Application Cursor Keys" (and "Application Keypad")
tput smkx ; cat
# Press Down Arrow to see '^[OB', then Control-C to kill the cat

# Activate "Normal Cursor Keys" (and "Normal Keypad")
tput rmkx ; cat 
# Press Down Arrow to see '^[[B', then Control-C to kill the cat

If you can somehow convince PuTTY to send xterm-style modified arrow key sequences (i.e. ^[[1;5B for Control+Down Arrow), then tmux will generate the same sequences for its panes when xterm-keys is enabled.

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.