enter image description hereI have a couple CLI utilities I would like to map to key combinations. The scripts take no parameters, I merely need to invoke them.

I've seen how to create keyboard shortcuts to apps, but can I point them to an executable somehow?

  • What exactly have you seen for creating keyboard shortcuts for apps as the same process could be adapted for executables? – grg Feb 25 '14 at 21:11
  • I just put a link in my question. The other examples I've seen are all the same. How to link keys to an application, but I haven't seen a place to enter a command instead. – quickshiftin Feb 25 '14 at 21:18
  • The link you've added refers to adding keyboard shortcuts to existing menu items in apps that are open. Do you want to have keyboard shortcuts perform key presses in Terminal CLIs, or run the CLIs themselves? – grg Feb 25 '14 at 21:20
  • Run the CLIs themselves. Ideally I just want to define a key combo, then enter an absolute path to a command to run. – quickshiftin Feb 25 '14 at 21:21

In your case, you would want to use Automator. You do not need to know about AppleScript to use Automator (in fact, if you open up Automator, you will quickly find that it really is self-evident).

The trick is not just to tie your CLI service to an Automator app, but to be able to get to that globally using a Keyboard shortcut. That can be achieved using a Service. This tutorial explains quite well how to do what you are looking for... in fact, describing a very similar scenario.

I take no credit for the tutorial content, only found it to solve a similar problem (I needed to map some drives at Startup without Finder.app opening while doing so).

|improve this answer|||||
  • This doesn't look like it will work. I navigated to the executable on my disk and it's greyed out. This is a BASH script I'm trying to launch, not an application. – quickshiftin Feb 25 '14 at 21:30
  • 1
    Assuming you have a script.sh of some sort, open up Automator. Choose Service Receives: 'no input' in 'any application' Under Actions, choose Utilities. Drag 'Run Shell Script' to your workflow. Enter the path to the script file there. Test it right in the Automator interface. – Chad Kemp Feb 25 '14 at 21:49
  • I've found the 'Run Shell Script' now, but don't see the new service in Settings when trying to add the keyboard shortcut. – quickshiftin Feb 25 '14 at 21:51
  • Did you set Service Receives 'No Input' in 'Any Application'? – Chad Kemp Feb 25 '14 at 21:57
  • Yes, take a peak at the screenshot I just uploaded. – quickshiftin Feb 25 '14 at 21:59

You can also do this with Keyboard Maestro, using a macro such as this:

Upon hotkey ⌥⇧⌘S, execute AppleScript tell application "Terminal" activate set currentTab to do script ("echo hi") end tell

|improve this answer|||||
  • 1
    Thanks for this. I like the more native approach from the answer I accepted, but I never specified a preference in my question. +1 – quickshiftin Feb 26 '14 at 2:21

You must log in to answer this question.

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