A while back I pointed out a blog post by someone else, which described how to get C-left and C-right working in tmux and OS X. Now I noticed that I cannot resize windows in tmux. This is because tmux seems to expect xterm keys for C-arrow. The xterm keycodes for the arrow keys are:
- 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 3: And a very last update… It seems that tmux does not support bce (background color erase), which xterm does. This is a problem for progams like htop, vim, or mc. You will see rendering errors, if you do not fix this.
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:
This will create a new terminfo source file, which does not advertise the bce feature. You can install this with the following command:
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:
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:
The “1;” variant is otherwise not recognized by GNU readline on OS X.