Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] MacOS X - How to make a script executable with double click?
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
January 9, 2014 10:12 AM
I ran into this issue with MAME, as it's intended to be started from Terminal - which for most users isn't exactly what they are used to.
To start the executable, you'd normally "cd" to the directory where the binary is (mame64 in this example) and then execute the binary with ./mame64.
Double clicking the file works as well, if it weren't for the fact that the current directory is most likely not the application directory for mame.
So I wrote a little script, it's a text file with the extension ".command", for example "mame64.command":
#!/bin/sh
cd "$(dirname "$0")"
./mame64
Save the text file as "mame64.command", right click the file and choose "Get Info" and set it to "executable" next to the "owner" flag under "Permissions".
Double clicking this file will now change to this directory and execute the binary (mame64 in this example).