Passing alt/opt key sequence over ssh to remote host with iTerm

Solution 1:

A terminal connection, such as created by SSH, basically transfers characters, not keystrokes. There are some exceptions to this, such as the "return" key and CTRL+letter combinations, because they have been in use since time immemorial and have their own character codes, and some keys like the arrow keys are handled by sending multi-character sequences, but more "modern" inventions, such as ALT combinations (which did not exist on the 1970:s-era terminals of which modern terminal windows are the descendants) are simply not handled.

Some terminal programs provide various work-arounds for this. One such work-around is setting the eighth bit in the character code when the ALT key is pressed, but this breaks down if you use some other character encoding than 7-bit ASCII. A more sensible workaround is to prefix "alted" letters with an ESC character, so that typing Alt-A is the same as typing Escape and then A.

So you need to figure out which of these conventions tmux expects, and then configure iTerm2 to follow that convention. I don't use iTerm2 myself, but it seems to have "Meta" (set eighth bit) and "Esc+" options under "Keys" in the settings window.