Apple Intelligence is now available on iPhone, iPad, and Mac!

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to set system keyboard shortcuts via command line?

I was used to set up a new machine using a couple of `defaults write`.

I'm setting up a new Catalina MBP right now and my setup for keyboard shortcuts doesn't work anymore.


For instance, if I run

defaults write com.googlecode.iterm2 NSUserKeyEquivalents -dict-add "Advanced Paste…" -string "@~^v"

I can use

defaults read com.googlecode.iterm2 NSUserKeyEquivalents

to see it has been set, but it's not visible in System preferences, nor in the app's menu nor does it work.

When I delete this key and add it manually via system preferences, the above command gives the exact same result, but it's working.


How can I set up those keyboard shortcuts (global and app specific) on Catalina?


PS: Using

defaults write -app iTerm ...

doesn't work either and the same holds for any app I tried (Safari, Chrome, etc.)

Posted on Aug 4, 2020 12:15 AM

Reply
Question marked as Top-ranking reply

Posted on Aug 6, 2020 12:10 AM

Sometimes, the obvious is what's out of our minds and finally helps. Not here, unfortunately. Thanks for pointing this out.


Nevertheless, I found the answer in the meantime. I was missing to add it also to universalaccess.

defaults write com.apple.universalaccess com.apple.custommenu.apps -array-add "com.googlecode.iterm2"


Similar questions

4 replies
Question marked as Top-ranking reply

Aug 6, 2020 12:10 AM in response to Luis Sequeira1

Sometimes, the obvious is what's out of our minds and finally helps. Not here, unfortunately. Thanks for pointing this out.


Nevertheless, I found the answer in the meantime. I was missing to add it also to universalaccess.

defaults write com.apple.universalaccess com.apple.custommenu.apps -array-add "com.googlecode.iterm2"


Aug 4, 2020 11:26 AM in response to K. Silk

If an app doesn't store its shortcuts in the preference file, just adding them there won't make them magically appear. The app would have to go load them and if not programmed to do so, won't see them.


If the app doesn't use the default menu code provided by Apple, then displaying the shortcuts you add in System preferences may not be implemented by the app.

Aug 5, 2020 12:48 AM in response to Barney-15E

Of course I understand that an app won't work this way if it doesn't respect this.

As I stated before, if I add the shortcuts manually, it actually writes the same, at least the "defaults read" results in the same and the key works as expected.

Again: it was working for long until now and it also affects Safari (an apple application).


Does this happen to others as well?

How to set system keyboard shortcuts via command line?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.