44

I am using Mac OSX Lion. I have checked "Use Option key as Meta" in Terminal preferences. Although the Option key seems to work fine as Meta in Bash, when I use it in Tmux (over SSH) it does not work properly. I am trying to use TMUX shortcuts like ^b M-1 b M-2 etc. I can get these with the ESC key but not the Option key.

1
  • ^b Space with cycle through the various layouts
    – BeeZee
    Mar 22, 2014 at 14:03

5 Answers 5

28

I would suggest using iTerm2 instead of the default Terminal.app, as it is better for many reasons.

Specifically, you would be interested in iTerm2's options to map left/right option as "+Esc", which works much better than trying to have it emulate Meta for every purpose I can think of or have tried.

This setting is located under:

  • Preferences
    • Profiles
      • [select a profile]
        • Keys
3
  • 1
    I was looking for a reason to move to iTerm2 and here I have it. Thanks!!
    – Phani
    Sep 27, 2013 at 17:32
  • 19
    May I ask why you choose to set option to "+Esc" and not to "Meta" when it sounds like you're trying to use Meta-keys? What is the difference / why is "+Esc" better? Thanks!
    – NHDaly
    Mar 1, 2014 at 19:15
  • When you hover over the "Meta" and "+Esc" options in iTerm2, there's a tooltip that says "+Esc is the preferred setting for users who don't need the option key to enter diacritics or other special character."
    – dirn
    Aug 9, 2021 at 14:02
39

For other folks who find their way here via their favorite search engine, I was able to solve this problem by simply going to Preferences -> Profiles -> Keyboard and checking "Use Option as Meta key" for the terminal profile I'm using.

I'm running weechat under tmux, and default key bindings make heavy use of the meta key.

4
  • you save my day!
    – zx1986
    Feb 11, 2019 at 13:51
  • Thanks! I was looking for a way to solve this without having to switch to iTerm2.
    – Valdimar
    Apr 10, 2019 at 11:56
  • The issue with that approach is, you can't use a bunch of characters anymore on some keyboard layouts, like tilde, some brackets and backward slash for example ][{}\ May 19, 2020 at 19:19
  • Tip: You can do the same in iterm2 and also use ESC+
    – Hritik
    Sep 1, 2023 at 14:27
7

I'm also sticking to Terminal.app, and since no other answer solved the issue I'm adding my own that worked for me.

Besides configuring the current Profile in Terminal -> Preferences -> Profiles -> Select the profile to configure -> Keyboard and checking Use Option as Meta key, also look through the default list of bindings in the table just above and make sure that the combinations you want to assign are free. For me there were a few Option + Arrow keys that were interfering with tmux configuration to easily change between panes.

enter image description here

5

I had the same problem and none of the answers provided here worked. That is, I too had the iTerm2 [Option] key remapped to [+Esc] (aka. "fallback"-[META]) in my "Preferences -> Profiles -> Keyboard", as described in the other answers, but still could not change my tmux pane layout with [CTRL]-[b], [+Esc/META]-[DIGIT].

Then I found that under "Preferences -> Keys", there is a "Navigation Shortcuts" where [Option] + (any) [DIGIT] is mapped to "switch split panes" (remember [Option] is remapped to [+Esc], so that's a clear collision). Therefore, after un-setting that (to an empty key value), I finally can again comfortably resize my tmux panes with [CTRL]-[b], [+Esc/META]-[DIGIT] (instead of having to use [CTRL]-[b], (the real) [Esc], and then the desired layout [DIGIT]).

2

In my .zshrc I usually have the following set:

bindkey '^[[1;9C' forward-word
bindkey '^[[1;9D' backward-word

Within tmux sessions, I had to additionally include

bindkey '^[[1;3C' forward-word
bindkey '^[[1;3D' backward-word

You can figure out these codes by running read in a session, then pressing the keyboard shortcuts, e.g. Alt.

My keys are set as follows in iTerm2:

You must log in to answer this question.

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