12

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.

  • 1
    I am adding a bounty to this question. Is there some alternative solution? Can the keyboard shortcuts be symlinked and synced through Dropbox? I guess the problem then would be that one Mac might have custom app keyboard shortcuts for an app that isn't installed on the other Mac...? – Winterflags Aug 21 '17 at 11:14
  • 4
    I can’t add this as an answer as it may be taken down. If you are having trouble with the Apple stuff, I’m not sure why but it works for me between macs and even iOS devices, have you considered moving to a third-party solution such as Keyboard Maestro, which can be setup to use Dropbox to sync between computers? wiki.keyboardmaestro.com/Syncing_Macros_Between_Macs – jasonology Aug 22 '17 at 1:33
  • 2
    @jasonology I can't see any reason why offering that as an answer would be a problem. In fact, I'd encourage you to do just that! :) – Monomeeth Aug 22 '17 at 4:02
  • 1
    @jasonology Can KeyboardMaestro bind custom shortcuts for previously non-shortcuted items in the applications' menu bar? I.e. as System Preferences > Keyboard > Shortcuts > App Shortcuts? That would be the holy grail for a third-party app to replicate the System Preferences options imo. I don't know that it's possible with BetterTouchTool (maybe it is?). – Winterflags Aug 25 '17 at 16:43
  • 1
    @jasonology, thank you for the suggestion. I pulled the trigger on buying Keyb. Maestro and it's doing exactly what I want, including DB sync. I wonder why your answer is removed, as it's best for me. Winterflags, I migrated my SysPref ones to Maestro one by one, it's not that hard, and worth it. – SilverSideDown Sep 20 '17 at 14:01
5
+50

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'

  • These commands have been working strangely for me on newer macOS versions, specifically High Sierra and Mojave. By strangely, I mean I sometimes have to run the command multiple times on a new system before they have an effect. Difficult to isolate the problem since testing means reinstalling the system... – Wowfunhappy Oct 16 '18 at 0:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .