3

Just learning the ropes of my new MacBook Pro.

I have a linux workstation at the office that I use to host a number of tmux sessions, which represent whatever Im working on at a given time.

If out and about I will ssh into this workstation using iterm2 and tmux attach -t to any given session. In tmux I have certain keys bound to certain actions, specifically, I have the movement between panes bound to Alt+[HJKL] to move in a given direction.

I'll bet you can see the problem! Mac therefore No Alt key! Is there a way I can map the apple key (or some other key) to be recognised as Alt when ssh'd to this host? or even globally if its not a per host setting?

Thanks in advance

6
  • 1
    Alt is Opt, which should be a key on your keyboard.
    – nohillside
    Aug 10, 2019 at 20:45
  • In my tmux sessions option is not recognised as alt (I had already tried this) but decided to try it outside of tmux too in a simple ssh session with bash, where I can use the emacs style navigation to move backwards and forwards per word (alt-b and alt-f respectively). That also did not work (although Ctrl-A and Ctrl-E to move to the start and end of the line did work) implying in this context at least, Ctrl is Ctrl, but Alt is not Opt. Thanks for the suggestion though. ps. I Also tried Option-B & Option-F in a simple iterm tab (not sshing anywhere first), and this also did not work.
    – GeoSword
    Aug 11, 2019 at 6:39
  • Ah, so basically you want to press Option on your Mac and trigger an Alt-Sequence on the remote machine?
    – nohillside
    Aug 11, 2019 at 7:55
  • Correct. Or any other modifier key. I presume its something that might be set in iterm but Im not 100% sure on what I should be looking for.
    – GeoSword
    Aug 11, 2019 at 14:58

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .