I know that I can pin applications to the dock and launch them from there. However, is there a way to pin a program to the dock that is not an "application" in the MacOS sense, like a bash script for example?
4 Answers
You can drag any file to the right bar of the Dock (where the Trash and folders are), and execute it by clicking it.
To execute a shell script, you can save it as a .command file and the OS will pick it up.
Another alternative would be to create an Applescript application for your script, and use it like any application.

- 24,813
- 12
- 83
- 113
-
1This doesn't work for me. I set the file to executable and renamed the file from a `.sh` extension to a `.command` extension but clicking on it in the doc still opens it in Xcode instead of running it. Adding `#!/bin/zsh` as the first line also didn't do it. Ah! Changing it to open with Terminal.app as in JW.'s answer did work. Might be worth adding details to this answer for us noobs. But it does leave a `[Process completed]` Terminal window behind... – hippietrail Mar 04 '21 at 03:29
Rename it to something.command, and in its Get Info window, select Open With > Terminal.app. Then when you double-click it, it will launch the Terminal and run the script. You can drag that to the dock.

- 50,691
- 36
- 115
- 143
The Script Editor can create applications based on AppleScript. Stick the following code into a script and save it as an application:
do shell script "~/someScript.sh"
Where ~/someScript.sh
is the path to your shell script.

- 14,220
- 3
- 41
- 65
-
-
Is your script executable, meduz? And do you have a shebang line at the top? ( http://en.wikipedia.org/wiki/Shebang_%28Unix%29 ) – Samir Talwar Feb 12 '14 at 15:22
-
I've set it to be executable but the sh file and the scpt file. I drag the scpt to the dock and click on it. All it does is open up the script editor again. How do you make it actually run the script when you click on it? – Jistanidiot Nov 27 '17 at 13:42
There are also tools to make applications from shell scripts, perl, python etc. There's DropScript and Platypus that I know of. They have the advantage that you can drag and drop files onto them.

- 11,957
- 7
- 46
- 68