2

I'm trying to get used to a macOS development environment after years of being an i3 junkie and I want to be able to use keyboard shortcuts to launch applications. I learned that you can do this by writing simple Automator services and then making keyboard shortcuts to those services (under System Preferences -> Keyboard -> Shortcuts -> Services). I followed the instructions here and I now have the Automator service I need in place and I can also tell it to use a shortcut like ++T to open it.

However, I don't want to use ++T to open a terminal. I would like to use +return instead. When I try to do that, System Preferences acts as though I haven't specified any shortcut at all; I think it doesn't like to set up shortcuts involving the return key. It lets you use most other keys though, as far as I can tell. (aside: I played around and it looks like the only keys you aren't allowed to use in this menu are return, delete, caps lock and fn.)

Does anyone know a way to work around that?

  • An ideal workaround would let me set it up directly in the System Preferences Menu. (that feels impossible to me so far but I have no idea why)
  • Second place would be doing it using config files somewhere on the filesystem. (akin something like an ~/.xbindkeys file under X11).
  • Least desirable to me are solutions involving installing third-party keyboard automation tools. (I think I can figure out how to do that on my own, I'd just like to avoid it.)

I'm using macOS Catalina.

0

1 Answer 1

2

Does anyone know a way to work around that?

  • Second place would be doing it using config files somewhere on the filesystem.

In macOS Catalina, it's the ~Library/Preferences/pbs.plist file that stores information about the services listed at: System Preferences > Keyboard > Shortcuts > Services

This answer is mainly focused on applying the ⌘↩ (commandreturn) keyboard shortcut to a service listed at System Preferences > Keyboard > Shortcuts > Services and without concern to the issues with creating an Automator Service/Quick Action and assigning it a global keyboard shortcut in reference to System Preferences > Security & Privacy > Privacy.

Having created an Automator Service/Quick Action and assigned it a temporary global keyboard shortcut of ⌘] in System Preferences > Keyboard > Shortcuts > Services, I then did the following to change it to: ⌘↩

Note: The name of the target Automator Service/Quick Action is: New Terminal Window

Closed: System Preferences

Opened: Terminal

% defaults read pbs | grep 'New Terminal Window'
        "(null) - New Terminal Window - runWorkflowAsService" =         {
%
% /usr/libexec/PlistBuddy -c "set :NSServicesStatus:'(null) - New Terminal Window - runWorkflowAsService':key_equivalent @↩" ~/Library/Preferences/pbs.plist
% 

Then went to System Preferences > Keyboard > Shortcuts > Services and verified the target Automator Service/Quick Action had the ⌘↩ keyboard shortcut.

I then pressed the ⌘↩ keyboard shortcut, responded to the Security & Privacy dialog box, and now have a new Terminal window.


Notes:

If after running the PlistBudy command and then checking System Preferences > Keyboard > Shortcuts > Services to see that ⌘↩ was assigned to the target service's keyboard shortcut and testing... If the ⌘↩ keyboard shortcut doesn't work, try the following before rebooting:

  • Try the the service from the Services menu, then try agin with the ⌘↩ keyboard shortcut.
  • If that does't work, execute the PlistBudy command again while appending ; killall cfprefsd to the command. Then repeat the step above.
  • If nether of these steps work, execute the PlistBudy command again and immediately reboot.

This was done from an Admin account.

This was done under macOS Catalina with Language & Region settings in System Preferences set to English (US) — Primary and worked for me without issue1.

  • 1 Assumes necessary and appropriate setting in System Preferences > Security & Privacy > Privacy have been set/addressed as needed.

The AppleScript code used in a Run AppleScript action of the Automator Service/Quick Action was coded to work whether or not Terminal was already running.


enter image description here

2
  • Wow, great answer! Thank you! I was in the same situation as you (admin account, US-localized English). Note for anyone else, I did have to reboot before the use of PlistBuddy took effect and replaced my shortcut.
    – sinback
    May 6, 2021 at 11:37
  • @sinback, I've added an additional note staringt at the top of the Notes: section... If after running the PlistBudy command...` and while it not applicable to you now that you've rebooted, hopefully it will benefit others, or you the next time you need to employ the method presented herein. Thanks. May 6, 2021 at 12:24

You must log in to answer this question.

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