[bash] How do I make this file.sh executable via double click?

First off I'm using Mac.

Next, I need to execute this "file.sh" we will call it. Everytime I need to execute it I have to open Terminal and type:

cd /Users/Jacob/Documents/folderWithFileInIt
bash file.sh

This is okay, but I feel like it would be a lot quicker if I make the file execute on double click, don't you think?

So my question is, how do I make this file executable via double click?

My ideas were either:

a) type something like chmod into terminal and change permissions?

b) make a file, put code I wrote above in it ^ and then make that file executable?

c) make an automation somehow to do this?

Which way is best, or is there an even better way? Also please explain as much as you can, I'm new to Terminal. Thanks.

This question is related to bash macos terminal executable

The answer is


You can just tell Finder to open the .sh file in Terminal:

  1. Select the file
  2. Get Info (cmd-i) on it
  3. In the "Open with" section, choose "Other…" in the popup menu
  4. Choose Terminal as the application

This will have the exact same effect as renaming it to .command except… you don't have to rename it :)


you can change the file executable by using chmod like this

chmod 755 file.sh

and use this command for execute

./file.sh

Remove the extension altogether and then double-click it. Most system shell scripts are like this. As long as it has a shebang it will work.


  1. Launch Terminal
  2. Type -> nano fileName
  3. Paste Batch file content and save it
  4. Type -> chmod +x fileName
  5. It will create exe file now you can double click and it.

File name should in under double quotes. Since i am using Mac->In my case content of batch file is

cd /Users/yourName/Documents/SeleniumServer

java -jar selenium-server-standalone-3.3.1.jar -role hub

It will work for sure


Examples related to bash

Comparing a variable with a string python not working when redirecting from bash script Zipping a file in bash fails How do I prevent Conda from activating the base environment by default? Get first line of a shell command's output Fixing a systemd service 203/EXEC failure (no such file or directory) /bin/sh: apt-get: not found VSCode Change Default Terminal Run bash command on jenkins pipeline How to check if the docker engine and a docker container are running? How to switch Python versions in Terminal?

Examples related to macos

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

Examples related to terminal

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave Flutter command not found VSCode Change Default Terminal How to switch Python versions in Terminal? How to open the terminal in Atom? Color theme for VS Code integrated terminal How to edit a text file in my terminal How to open google chrome from terminal? Switch between python 2.7 and python 3.5 on Mac OS X

Examples related to executable

Running .sh scripts in Git Bash Pyinstaller setting icons don't change How to compile python script to binary executable How can I find out if an .EXE has Command-Line Options? How do I make this file.sh executable via double click? run program in Python shell Running EXE with parameters Creating a batch file, for simple javac and java command execution How can I make a Python script standalone executable to run without ANY dependency? Difference between Groovy Binary and Source release?