In my normal terminal, F1–F4 keys produce ^[[11~^[[12~^[[13~^[[14~
, but in tmux I get ^[OP^[OQ^[OR^[OS
. I'd like them to behave the same in tmux so I don't have muck around with bindings for programs in tmux. I don't have PuTTY's Xterm R6 option on.
I'm using putty-256color
as my terminal type both from putty and in tmux to get around other keys being mismatched, though I still have to remap my arrow keys.
Config is was:
set -g default-terminal "putty-256color"
set -g terminal-overrides "putty*:smkx@:rmkx@:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:kf1=\e[11~:kf2=\e[12~:kf3=\e[13~:kf4=\e[14~"
The rest of my config is unrelated cosmetic stuff. You can see I've tried to remap the 4 function keys back to original, but I haven't got it to work.
I feel like I'm missing something fundamental, why can't my keys stay the same for every key inside and outside tmux, with the exception of prefix so these issues do not occur?
Edit
My problem still exists but I was missing something fundamental: default-terminal
refers to the terminal type within tmux but terminal-overrides
refers to the term type I'm connecting with, i.e. outside of tmux. (Yes, I feel stupid.)
My config is now like so:
set -g default-terminal "screen-256color"
set -g terminal-overrides "putty*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:kf1=\e[11~:kf2=\e[12~:kf3=\e[13~:kf4=\e[14~:smkx@:rmkx@"
F1–F4 still give me ^[[11~^[[12~^[[13~^[[14~
outside of tmux, and ^[OP^[OQ^[OR^[OS
inside.
Best Answer
The manual page is not clear, but reading the source code helps:
input_key
Your shell is the application that the comment refers to.
The
terminal-overrides
is used to modify the terminal description whichtmux
reads, to allow you to work with configurations (of the external "real" terminal) which do not match the terminal description:tmux
translates keys into its own set of escape sequences (matching the ones inscreen
, with the exception that it adds thexterm-keys
option). The comment at the top ofwindow.c
summarizes this:The manual page says
The reason for the restriction is that there's no way to customize the data in
input-keys.c
in the way you would like.