How To Use Option as Meta Key in macOS Terminal?

  • HOME
  • >
  • MAC
  • >
  • How To Use Option as Meta Key in macOS Terminal?
Last Updated: 

What is the Meta Key ?

The Meta Key (denoted as M or Meta) is a modifier key which mean it temporarily modify the normal action of another key when pressed together. Common modifier keys are shift, alt, or control. The meta key was a special modifier key marked with a solid diamond . Bash uses some meta keys combination for some advanced control that can quickly improve your velocity and productivity on the shell.

Unfortunately, keyboards without a meta key, and on macOS, this mean that meta key is replaced by the esc key which is not convenient at all and often more clunky than helpful. Though, you can have your macOS Terminal configured to use the option key as a meta key.

Why using Option as Meta Key?

With the meta key properly set for your Terminal, you can quickly improve your shell productivity by using some of the following sequences; assuming that you use the default bash keybindings which is based of emacs.

M+f Move forward one word (vs per character)
M+b Move backward one word (vs per character)
M+u Uppercase a full word, starting at cursor
M+ul Lowercase a full word, starting at cursor
M+d Delete word forward from cursorv
M+delete Delete word backward from cursor
M+s Swap current word with previous word

How to Configure Terminal to Use Option as Meta Key?

You can programmtically configure your Terminal using defaults. If you are not familiar with this command line tool on macOS, check the post How To Change Preferences from the Command Line on macOS?.

The domain for the Terminal app is com.apple.Terminal. You will need to look for your default Window Setting with the key Default Window Settings. Then, based of this, look at the corresponding nested dictionary inside the dictionnary Window Settings and set the key useOptionAsMetaKey to 1.

Alternatively, instead of using defaults in the command line, you can simply go to the Terminal > Preferences... (or type +,). Then, Profiles > Keyboard and check the box Use Option as Meta key. Though, this wouldn't be as fun.

Related mac posts that you may like...
How To Format Date and Time in Linux, macOS, and Bash?
This guide covers how to format date and time in Linux, Mac, and the Bash shell. Includes how to do date shell operations like adding days or comparing dates.
How To Change Preferences from the Command Line on macOS?
Introduction to the command line 'defaults' on Mac with examples on how to programmatically change user preferences from a shell script and terminal.
How To Upgrade your Bash Version on Mac OS?
MacOS comes with an outdated version Bash which can be limiting in shell scripts. This post explain how to upgrade your Bash version on Mac from the command line.
How to Find which macOS version you are running?
Find out which macOS version you are currently running with the use of two command line tools named respectively system_profiler and sw_vers.