Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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 com.apple.keyboard.modifiermapping.* 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.