Sometimes it's better to launch your script with a mouse click and not the Terminal. You don't need to launch CLI, type in the command, wait until it finishes and then close it. You can launch your written script like any other OS X application – using its icon.
It could be short code that makes backup of some files in your system, moves the backup and informs if the process succeeded. Anything that you can do with Apple script, you can have it as separate .app file, which could later be started from OS X Launchpad.
In my case, I needed separate .app file to launch Zenmap. The original program links to
/Applications/Zenmap.app/Contents/MacOS/Zenmap during the startup, but it just doesn't work on OS X El Capitan. This is a known bug, but until it's fixed, I had to find another solution. By experimenting, I found out that it perfectly works when linked directly to .bin file of this application. That's why I made this simple script.
Steps to create .app file with Apple Script
- Open Script Editor using Launchpad or Spotlight.
Type in the code which does something you need.
do shell script "/Applications/Zenmap.app/Contents/MacOS/Zenmap.bin" password "yourpassword" with administrator privileges
Refer to official Apple Script documentation for more information about supported commands.
- After typing all the needed commands, press File and Export in the top menu bar.
- Choose File format as Application. If your code requires administrative privileges and you typed in your password in the script like I did, I highly recommend you to mark the script as Run-only. This will prevent editing the file.
- Save the file. You can now use it as a regular OS X application with .app extension.
To make it even more user friendly, we can add custom icon to it. To do this, right click on newly created file and press Get Info. When the info window opens, drag .icns file on Apple Script icon in the top left corner. Your final application should look something like this in Launchpad:
In my case, it was just a really simple script that I needed to be able to access from Launchpad. I am sure that this Apple Script functionality could be really useful for more complex pieces of code.