Creating Mac Applications from Shell ScriptsAugust 28, 2012
In the past, I’ve used a variety of methods to turn shell scripts into native applications. Each method has its own pros and cons, which I will attempt to explain in this post.
Playpus used to be the “go to” solution for packaging shell scripts as native applications. It supports a wide variety of scripts, including shell, Perl, Python and PHP. Platypus is very old, and surprisingly, is still being maintained and developed. Platypus also has a command line tool which allows the automation of the script to application process and also makes it comparable to Appify.
Appify is a relatively new solution for those who are looking to convert shell scripts into applications. All of the work done by Appify appears to take place in under 15 lines of shell code (it is a shell script itself). It was created by Thomas Alyott of Subtle Gradient and the version linked above was modified by Mathias Bynens. Appify is extremely simple, lightweight, quick, and easy to use. All that is needed to be done in order to create an application from a shellscript is the following:
$ appify your-shell-script.sh "Your App Name"
Clickable Shell Scripts in Finder
If you aren’t looking to distribute your shell script as an application and only want a way to quickly execute a shellscript by clicking on it, there is another solution which involves SetFile. However, there are multiple downsides to this: the script isn’t distributable, anyone who you send the script to will have to run the command as well in order to make it clickable. This method also requires Apple Developer Tools, so a large majority of Mac users out there won’t be able to use it. To create a clickable shell script, run this through your command line:
SetFile -t APPL name-of-script.sh
Manually Creating the Executable
This is essentially what Appify does when you feed it a shell script, but you can do it all manually in Terminal:
mkdir -p name-you-want.app/Contents/MacOS mv mame-of-script.sh name-you-want.app/Contents/MacOS/foo chmod +x name-you-want.app/Contents/MacOS/foo
There are several ways to convert shell scripts into applications. Platypus offers the most custimization and options in a GUI, Appify is the quickest way to create one from the command line, and SetFile is a good solution for your own personal use (not intending to distribute).