How do I launch a bash script from Finder in OS X?

14

2

How do I launch a bash script from Finder in OS X?

I'm OK working at the CLI, but my little script is not so loved by my GUI-bound colleagues.

Stu Thompson

Posted 2009-09-10T08:10:33.210

Reputation: 1 106

Answers

23

For being Finder friendly, a bash script must have the .command suffix. Of course it must be executable as well.

mouviciel

Posted 2009-09-10T08:10:33.210

Reputation: 2 858

chmod +x filename.ext to make it executable – Hefewe1zen – 2017-05-17T23:52:56.507

1You just won my world famous "Geek Hero of the Day" award! Thanks. – Stu Thompson – 2009-09-10T08:20:19.057

This answer made the question interesting. – Sergio Acosta – 2009-09-10T09:16:49.910

1fyi, if anyone tries to softlink to a script, the script itself (the destination of the softlink) has to end in .command, and the link itself can have any extension. weird, I know. – AlcubierreDrive – 2012-02-28T01:54:27.087

5

@mouviciel's answer will work great, but for added panache, try Platypus, which allows you to create actual Application Bundles from various scripting languages, including Bash shell scripts. One of the advantages to this is you can give it a nice looking icon :)

Jon Grant

Posted 2009-09-10T08:10:33.210

Reputation: 3 692

1

I've just released bashapp via github, which compiles a bash script into a binary program (C source) and creates the directory structure necessary to make it clickable in Finder. Here's the README:

http://github.com/arbinger/bashapp

I needed this to build a few service launch scripts that could be clicked on in Finder, as opposed to asking users to open a Terminal. It also provides simple script obfuscation via encryption, which can be handy if you need to distribute the program.

If you wanted to add icons, you can do so by adding the Info.plist file, and the .icns file to the Contents/Resources/ folder.

jar

Posted 2009-09-10T08:10:33.210

Reputation: 81