6

I have a .sh file with a #!/bin/bash header. I'm able to run it from the terminal, using chmod and ./ but is there a way to perform these two operations from the desktop (i.e. by clicking on it) ?

Btw, I'm familiar with linux, but not with OS X.

2
  • Which operation do you want to perform from the desktop? The chmod or executing the script? Are you looking for a desktop shortcut to execute one specific script, or easy access to the shell from within the GUI?
    – Gerry
    Feb 1, 2013 at 14:40
  • I'm not entirely sure what you mean but if you just want to double click on it and have it run you need to change the extension to .command. This will open it up in a terminal.
    – Tony
    Feb 1, 2013 at 20:31

3 Answers 3

7

You can add a .command extension to your text script.

Then use chmod 744 to make it executable.

When opened or double-clicked in the Finder it will then run from the Terminal.

4

Well you can wrap it inside a AppleScript, make a call to shell command (your bash script).

example: do shell script

do shell script "/bin/tcsh my-command-file-path"

save it as an application to your Desktop to run it.

3

You can put any commands into an AppleScript, and save the script as an applet, or a droplet, or use Automator to create applets and/or droplets. Just use the do shell script command in the AppleScript.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .