OS X doesn’t allow shell scripts to run as Login Items. Adding a shell script as a login item causes the script to be opened in an editor; not exactly what I had in mind. Login items need to be applications, but how do you convert a shell script into an application? Easy: Platypus.
Platypus is an open source project that packages up scripts as Mac applications. It works with pretty much any scripting language you can think of. It’s a really simple concept and it works well.
To convert a simple shell script into an application using Platypus you’ll need to follow these steps:
- Enter the name of the application you want to generate. This will be the name of the file and what appears in the Finder, so be as descriptive as you need to be.
- Select the type of script being wrapped and configure any arguments to the interpreter. If you’re wrapping a shell script you won’t need to do this as the default will work just fine.
- Select the path to the script to wrap up as an application either by using the Select button or dragging and dropping the script into the field.
- If the script generates output you might want to configure the output format. If there is no output from the application, or you don’t care about the output you can safely select “None”.
There are a bunch of other options such as the icon to use for the generated application, additional files to bundle, etc. Since I wanted my application to be used as a Login Item I wanted it to be as unintrusive as possible. The configuration options for my application were:
- Set “Output Type” to “None”.
- Check the “Run with Administrator privileges” checkbox.
- Check the “Run in background” checkbox.
- Uncheck the “Remain running after initial execution” checkbox.