azalea says

Setting up Mac OS X and iTerm2 for Emacs

I’ve been taking the Startup Engineering class on Coursera, which gives me a reason to give Emacs a second chance. The class covers setting up Terminal for Emacs in Mac OS X. However, I use iTerm2 (a fantastic replacement for Terminal), so I have to do some research myself.

Emacs commands use the control key (referred to as C-) and the META key (referred to as M-), but in MAC OS X, by default, they are located far away from the center of the keyboard.

Our goals are:

  • Remap left option to META
  • Switch left option and left command
  • Remap caps lock to control

Remap left option to META

Emacs interprets esc as META (M-), but esc is so inconveniently located. Thus we remap the left option key as esc.

iTerm2 -> Preferences -> Profiles

iTerm2 Preferences Profiles

Switch left option and left command

Optional, but it is more convenient to place META right next to the space bar.

System Preferences -> Accessibility

System Preferences Accessibility

iTerm2 -> Preferences -> Keys

iTerm2 Preferences Keys

Remap caps lock to control

caps lock is rarely used, so we put it into better use as the control key. Unfortunately, iTerm2 does not support remapping the caps lock key, yet. So we have to change the mapping globally for the entire OS.

System Preferences -> Keyboard

System Preferences Keyboard


I am indebted to this post for the title, and this post for the inspiration of using screenshots.

emacs Mac OS X · Tweet Edit