Use Option as Meta Key in Mac Terminal

Feb 1, 2013 - 6 Comments

Meta key in Mac OS X Terminal

By turning Option into the Meta key, you will be able to use familiar meta commands to jump around and navigate text in places like Emacs or bash shell without twisting your fingers around to poke at Esc. This won’t be applicable or useful to everyone, but it’s one of those must-use tricks for frequent terminal users or for anyone coming to the Mac OS platform from a background in unix.

How to Use Option / ALT as Meta in macOS Terminal

For Terminal in modern versions of macOS, like Monterey and Big Sur:

  1. Pull down the Terminal menu and choose “Preferences
  2. Go to the “Profiles” tab and select the active profile in use
  3. Choose the “Keyboards” tab
  4. Check the box to enable “Use option as Meta key”

Use option as META key in Terminal for Mac

How to Use Option/ALT as Meta Key in Mac OS X Terminal

For older versions of Terminal in Mac OS X like Mavericks and earlier, to use the Option key as a Meta key in the Mac OS X Terminal app:

  1. Open Terminal and pull down the primary Terminal menu to choose “Preferences”
  2. Under the “Settings” section, find your default Terminal and click the “Keyboard” subsetting tab
  3. Check the little box for “Use option as meta key” at the bottom of the window

Enable Meta key as Option in Mac OS X Terminal

Changes take effect immediately for all terminal windows using that. You can test it out by using commands like Option+B to jump forward a word, and Option+F to move back by a word, Option+M to return to the beginning of a line, and so on. The meta shortcuts are different from the standard text navigation shortcuts that are tied to the Control key and that work pretty much everywhere in Terminal and often across GUI based apps in macOS and Mac OS X too.

If you didn’t know, the meta is enabled by default in macOS and Mac OS X Terminal, but it’s assigned to the Escape key which isn’t particularly useful for those of us who are accustomed to the control, alt option, and command keys being used for keystroke shortcuts.

iTerm users can also make this change in the Profiles section of Preferences.

.

Related articles:

Posted by: William Pearson in Command Line, Tips & Tricks

6 Comments

» Comments RSS Feed

  1. Habib Alamin says:

    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.

  2. sophie says:

    Hi,
    It’d be great if we could duplicate Control and Option keys to the same function in Terminal.

    e.g
    Control-C = ^C
    Option-C = ^C

    I’ve don’t how!

  3. José Fortes says:

    Thank you for me suggestion, but I found that it isn’t as convenient as it initially seemed, because (with Spanish keyboard on Snow Leopard) after checking “use option as meta key”, the alt key can no longer be used to produce any of the following charactrers: ~#¬]}|\ which of course are important in a terminal/emacs context! It would be fine if the only alt key affected by checking the box were the left alt key, while the right one retaining its ability to produce those characters.

    • Daniele Passerone says:

      Dear José

      I was looking around because I have exactly the same problem. Did you find a solution in the meanwhile?

      • Harold says:

        In case you never found a solution to this, iTerm 2 supports having different behavior for the left and right option keys.

        I use left option for meta and leave right option alone for typing special characters.

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site