Sync keyboard shortcuts between macOS computers

I have a couple of custom shortcuts defined using System preferences > Keyboard > Shortcuts and I want to sync those between my two Macs.

It seems, this is still not possible using iCloud. Are there any other ways? I thought about including them into my dotfiles, but can not find the shortcuts using the defaults command.


Since you're using dot files, if you know what shortcuts you want to create ahead of time, you can add them to all machines by adding the following defaults write commands to your setup script:

Per App Shortcuts: defaults write com.developer.app NSUserKeyEquivalents -dict-add "Menu Item" -string "keyboardShortcut"

Global Shortcuts: defaults write -g NSUserKeyEquivalents -dict-add "Menu Item" -string "keyboardShortcut"

...where com.developer.app is the application's bundle ID, and keyboardShortcut is the letters of the keys you want to include, plus the symbols @, $, ~, and ^ representing the Command, Shift, Alt, and Control keys, respectively. For example, -string "@~K" would represent the keyboard shortcut K.


If you need to sync existing shortcuts, you're going to have to make a more complicated script. I imagine this would involve reading or comparing shortcuts on a source machine via:

Per App Shortcuts: defaults read com.developer.app NSUserKeyEquivalents

Global Shortcuts: defaults read -g NSUserKeyEquivalents

...and writing them to a target machine via:

Per App Shortcuts: defaults write com.developer.app NSUserKeyEquivalents 'outputOfSourceMachine'

Global Shortcuts: defaults write -g NSUserKeyEquivalents 'outputOfSourceMachine'