Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My tribe like to switch their control and caps lock keys. I know how to do this† from the GUI. I'd like to go one step further, and put this step in my nascent dotfiles/osx file. Does anyone know how to do this from the command line, say using the defaults command?

† If you have more than one keyboard (e.g. you use an external keyboard with your notebook), you must remap each keyboard, while they are attached, using the dropdown on the preferences dialog.

share|improve this question
I see that this changes the file ~/Library/Preferences/ByHost/.GlobalPreferences.*.plist (where * is actually a UUID which I expect identifies the host). Inside this file, an array named* is modified, where this * identifies the keyboard. How to alter this in a predictable way from the command line, I don't know. But at least, it is a starting point. – Harald Hanche-Olsen Aug 28 '12 at 16:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.