10

I check "Use option as meta key" checkbox in Mac OS X Terminal, because I like to use emacs way of moving between words: M-f & M-b.

But if I do that, I can't get the backslash (Option + º; i.e.: Option + key-at-the-left-of-1-in-spanish-keyboard). If I uncheck it, then I can input the backslash, but I don't have M-f & M-b.

Is there a way to get both?

Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
nephewtom
  • 2,941
  • 3
  • 35
  • 49
  • 1
    This probably belongs on SuperUser.com or better yet, Apple.StackExchange.com – ocodo Jan 27 '11 at 00:51
  • 1
    +1 for letting me understand that there was a "Use option as meta key" box. – JnBrymn Feb 03 '11 at 04:01
  • I have the same problem with my usual french (Azerty) layout. Under other OSes (Win and Linux), I can map (left)Alt as META, while (right)AltGr allows me to input alternative grahics. I can thus navigate efficiently **and** input all the characters available on my layout. I am still to find a way to achieve this under OS X *Terminal*, not finding any accepted answer here makes it look difficult. – Ad N Dec 04 '13 at 14:57
  • Cross-site duplicate https://apple.stackexchange.com/questions/7084/mac-os-x-terminal-use-option-as-meta-key-overrides-backslash-in-spanish-keyboa – tripleee Nov 19 '20 at 14:58

6 Answers6

2

The escape key works as a meta key by default; no need to use option as the meta key (other than its more convenient location).

chepner
  • 497,756
  • 71
  • 530
  • 681
  • 2
    The Option key is also a lot easier to type fluidly, because it's a modifier key. To use ESC you have to press and release the key, then type the key you want to modify. – Chris Page Jul 04 '12 at 23:03
  • The first part of the answer would make for an interesting comment (not an answer obviously), the part about it being "not needed" is a respectable opinion, but will not help anyone who needs this functionality (eg. Linux background). – Ad N Dec 04 '13 at 14:54
  • Thank you! Despite the whiney, this is the only answer with an explanation on how to use the META key without tweaking the macos keyboard! – MensSana Sep 01 '20 at 19:06
1

You could customize the keyboard map to use a different key for entering backslash. Look in

Preferences > Settings > [profile] > Keyboard

For example, you could map Control-F1 to backslash.

Note that the default keyboard map maps Option-Left/Right Arrow to M-b/f, so you could use those instead of using Option for Meta (you’d have to get used to using the arrow keys instead of b and f, but I’ve never been able to get used to using b and f and prefer the arrow keys).

Chris Page
  • 18,263
  • 4
  • 39
  • 47
1

Not a great solution, but XTerm (running in X11 on OS X) can use CMD as the Meta key.

You might also have some good results from KeyRemap4MacBook.

Just as a side benefit, XTerm should also give you proper terminal mouse interaction, e.g. in Emacs or ncurses based apps.

ocodo
  • 29,401
  • 18
  • 105
  • 117
1

You will most likely run into a lot more problems with that setup, because Mac OS uses "Alt" as a modifier in a lot of shortcuts. But anyway, including the following line in your ~/.bash_profile will send a backslash if you enter the unicode character "∫" (which is E288AB):

bind '"\033\xE2\x88\xAB"':'"\\"'
Asmus
  • 5,117
  • 1
  • 16
  • 21
0

I had the same issue. This is how I solved it.

I replaced the built in terminal with iTerm2, which also gave me a few other nice features. To get a sane Meta-key i did the following:

For the profile I wanted to use I checked "Alt sends +Esc", which gave me back a sane Meta-key that works in Emacs, Bash and others. However, I did lose the backslash key. So, to get it back and added a binding in the profile that does "Send text: \" and then I bound it to my backspace key combo (Shift-Alt-7, I'm Norwegian).

Now I have M-f, M-b in Emacs, M-. in Bash and I'm able to send backslashes. I also have a "Visor shell session" that I can have slide down by pressing another key combination.

perbu
  • 390
  • 1
  • 7
0

This is years late, but for people coming across this page whilst searching for a solution, as I did, I have decided to build one myself.

It is a simple status bar app that runs in the background and rewrites all left-Alt + $KEY key events to two key events in rapid succession, Esc, then $KEY; however, it only does this if Terminal.app is the focused application.

You can find it here at https://github.com/habibalamin/Metalt.

habibalamin
  • 31
  • 1
  • 9