osx - Launch shell scripts via keyboard shortcut in Mac OS X

22
2013-10
  • user479534

    The only workaround I am aware of is using applescript in Spark/FastScripts with

    do shell script "python script.py"
    
  • Answers
  • Arjan

    In 10.6 Snow Leopard it's quite easy to add any command to the Services menu of each application (or specific applications), and then assign a keyboard shortcut.

    Here on Super User, see Fast User Switching/Apple Menu? for an example that invokes some shell script.

  • John T

    You can use Keyboard Maestro to launch an application or script from the keyboard. There is also IronAHK (AutoHotkey rewrite) which works under Mono, example:

    ^n::Run, /path/to/script.py

    although make sure the script has sufficient execute permissions and a shebang line.

  • Fred

    You can also use automator to make a contextual menu invoked script.

  • Kio Dane

    Other applications that launch AppleScripts like FastScripts (lite) include Quicksilver, Butler, and ControllerMate.

    I believe Quicksilver may allow for the execution of Shell scripts directly from within the application, but I dislike Quicksilver on the point that it seems to flake out more often than Butler does.

  • flarn2006

    Personally I don't see anything wrong with your workaround. It seems like a perfect solution, so much so that when I found this question in a Google search, that's the one I used. Thanks! :-)


  • Related Question

    osx - Switching between keyboards in mac - shortcut key?
  • alok

    What shortcut key do you use to switch keyboards on your mac? Windows uses Alt + Shift, and on the Mac the default is Apple + Space. However, that's also the shortcut for spotlight.

    I ended up disabling the spotlight shortcut.

    What's your preferred keyboard switching shortcut?


  • Related Answers
  • Jasper

    On a Mac I use Command + Shift + Z to switch languages. I was already used to Alt + Shift from Windows and, since Command + Shift alone wasn't a valid combo, I just added the nearest key (Z).

  • Jasper

    Since I use GNOME-DO on Linux, and used to use Google Desktop Search on Windows, I changed the spotlight shortcut to Ctrl + Space, and use Apple + Space for language switching.