skip to content

Tmux, Iterm2 And Meta Keys

In September, someone posted on reddit about not being able to get his Tmux configuration work when SSHing into Ubuntu 10.04 from a Mac running iTerm2.

The source of the problem is iTerm2 sending \e[1;9A - \e[1;9D for ⌥ + arrow keys. I asked @gnachman why iTerm2 sends \e[1;9A - \e[1;9D and not \e[1;3A - \e[1;3D and he answered 9 was inherited from the old iTerm (see the conversation on Twitter).

To complicate things further, tmux up to version 1.8 used to remap \e[1;9A - \e[1;9D to \e[\e[A - \e[\e[D. Then tmux 1.9 and 1.9a stopped doing so while tmux master branch does it again after commit 193b6bcf36dda3754c99beb0dcc3dfdfceebdb09.

From there you have several options:

  • make iTerm2 send \e[1;3A - \e[1;3D by remapping keys in your profile
Send Escpape Sequence
  • make iTerm2 send \e[1;3A - \e[1;3D by running iTerm2 nightly starting from Build 2.9.20140911 and using the new advanced “Treat Option as Meta in escape codes send by typing arrow keys” option
Treat Option As Meta

Hope that helps!