I'm on a Mac, and have a bash script that works very nicely. I'd like to make it so that a double-click will run it, but I don't know the "open with" operand. Please, what am I missing?
-
Welcome .. You could put your Mac related question on apple.stackexchange.com or superuser.comfujy– fujy2013-09-14 16:43:05 +00:00Commented Sep 14, 2013 at 16:43
-
2possible duplicate of How to run a shell script in OS X by double-clicking?Barmar– Barmar2013-09-14 17:20:19 +00:00Commented Sep 14, 2013 at 17:20
-
after making it an executable run ./your_bash_fileuser3063755– user30637552013-12-03 23:59:06 +00:00Commented Dec 3, 2013 at 23:59
1 Answer
You'll need to make the file an executable. On the first line, before any of your code put in a shebang
#!/usr/bin/env bash
REST OF YOUR CODE HERE
Next, you'll need to change the permissions. On the terminal run:
chmod +x your_bash_file
Finally, you will need to make sure OS X opens the file using the Terminal and not the application that created the file e.g. your favourite text editor. You can accomplish this in 1 of two ways:
Save the file with no file extension (eg.
bash_file, instead ofbash_file.sh)Or, choose
File -> Get Infoand setOpen with:toTerminal.app
You should now be able to click on the script to execute it!
1 Comment
chmod u+x your_bash_file. There's no point giving group and other execute permission if it is not required