- left key: ^[[D
- right key: ^[[C
- up key: ^[[A
- down key: ^[[B
- C-left: ^[[1;5D
- C-right: ^[[1;5C
- C-up: ^[[1;5A
- C-down: ^[[1;5B
I can now configure OS X terminal to send those key codes, and tmux works fine. However, other apps running in tmux will break, because they don't expect to get xterm key codes. I found a workaround in the ArchWiki, which suggests to create your own terminfo entry. I will try that and report back here.
Update: The solution is adding two lines to the ~/.tmux.conf file:
set -g default-terminal "xterm-256color"
setw -g xterm-keys on
Update 2: And here is my OS X Terminal.app configuration:
So you need to make your own terminfo file and own terminal type, called xterm-256color-nobce. You can do this on the command line:
pi@raspberrypi ~ $ infocmp xterm-256color | sed 's/bce, //' | sed 's/xterm-256color/xterm-256color-bce/g' > xterm-256color-nobce
This will create a new terminfo source file, which does not advertise the bce feature. You can install this with the following command:
pi@raspberrypi ~ $ sudo tic ./xterm-256color-nobce
This makes the terminal type xterm-256color-nobce available. After this, change your ~/.tmux.conf once again, to use the new terminal type per default:
set -g default-terminal "xterm-256color-nobce"
Update 4: To make the Ctrl+Arrow keys also work in regular OS X Terminal, you need to edit or create ~/.inputrc to contain this:
# xterm keys for skipping a word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5C": forward-word
"\e[5D": backward-word