macosshelldock

Executing Shell Scripts from the OS X Dock?


How do I set up a shell script to execute from the Mac OSX dock? It seems that simply creating a shortcut will open the file in my editor. Is there a flag I need to set somewhere to tell it to run instead of opening it for editing?


Solution

  • You could create a Automator workflow with a single step - "Run Shell Script"

    Then File > Save As, and change the File Format to "Application". When you open the application, it will run the Shell Script step, executing the command, exiting after it completes.

    The benefit to this is it's really simple to do, and you can very easily get user input (say, selecting a bunch of files), then pass it to the input of the shell script (either to stdin, or as arguments).

    (Automator is in your /Applications folder!)

    Example workflow