X

Creating a double-clickable Terminal script

Creating a double-clickable Terminal script

CNET staff
2 min read
Using SETI@Home as an example, Remo Del Bello shares this tip for creating scripts that can be saved and launched from the OS X Finder. Although SETI@Home is the basis for this example, this can work for any task that requires typing a series of commands into the Terminal. He writes:

"I like running the SETI@Home darwin client since it is so much faster than the OS X 'screensaver,' and wastes less cycles. I really missed seeing the progress, so I would fire up Terminal, cd to the SETI@Home directory, run setiathome with the verbose flag and leave the window open. Eventually I got tired of typing all of that every time so I made the following little shell script:

#!/bin/sh
cd ~/Applications/setiathome-3.03/;
./setiathome -verbose

Seeking a way to avoid manually opening a Terminal window and typing the name of the script, I set out to find a way to make this script double-clickable. It turns out to be very simple to do. All you have to do is append '.command' to the end of the filename of an executable script. Alternatively, you can Get Info on the script in the Finder and select Terminal as the application to Open With if you don't want to change the name of your script. I now have a file called 'seti.command' that I just double-click and the whole thing is taken care of. Since I've discovered this I've made a number of shell scripts that I can just double-click to run and it is very handy."

Update: You also have to make the file executable by changing its permissions settings, via a utility such as XRay or directly in Terminal (via the chmod command). Philip Sharman found that .sh worked instead of .command, at least for sh shell scripts.