I wanted to associate the ".slfsrv" extension with the executable, so that one could run a .slfsrv program simply by double-clicking on the file in OSX's Finder or Windows' explorer. This was very easy in Windows but on the Mac it took me quite a while to figure out. It turns out you can't associate a file extension with a simple executable, it has to be a Mac App.
How to mac a Mac App from a darwin executable
To make a Mac App from a darwin executable
- Launch the Automator application
- Click "New Document"
- For document type select Application
- From the Actions library on the left select select "Run Shell Script" and drag that to the workplace on the right
- Change the "Pass input" option to "as arguments"
- Edit the shell script for what to be something like one of these:
for f in "$@"
- Select File/Save and create a name and location for your ".app" file. In my case I called this "SelfServing.app" and put it in my "~/bin" folder
You next want to associate a file extension with the .app you just created, as follows:
- In the finder open a folder containing a file of that type. In my case I opened the folder containing the file morninMenu.slfsrv
- Right click on the file and select "Get Info"
- Under "Open With" select "Other..." and locate the .app file you created from Automator (you probably want to have all files with that extension opened with your app).
That's it. Now you can run the command-line program on all files with that executable simply by double clicking that type of file in Finder, or from the command-line typing "open myfile.myextension"