Try changing your script to have .command
or .tool
extension, but possibly it could not work in the recent OS X.
However if you need the script to be an app, you should create one.
The basic structure of a Mac app is:
MyApp.app/
Contents/
Info.plist
MacOS/
Resources/
Then copy your script into MacOS/
(with the same name as your app), which should contain the application’s standalone executable code. All other resources goes into Resources/
.
Please have a look at appify script by Thomas (or Mathias version of it) which basically goes like:
#!/usr/bin/env bash
APPNAME=${2:-$(basename "$1" ".sh")}
DIR="$APPNAME.app/Contents/MacOS"
if [ -a "$APPNAME.app" ]; then
echo "$PWD/$APPNAME.app already exists :("
exit 1
fi
mkdir -p "$DIR"
cp "$1" "$DIR/$APPNAME"
chmod +x "$DIR/$APPNAME"
echo "$PWD/$APPNAME.app"
Usage:
appify foo.sh "Bar"
Source: How to create simple Mac apps from shell scripts
Alternatively you can use:
- DropScript which lets you create new applications (such as scripts written in sh, perl, etc.).
- Platypus - an app which creates native Mac OS X applications from interpreted scripts such as shell scripts or Perl, Ruby and Python programs.
- Create it in some IDE (such as Eclipse) which have such options to do it.
Or create it manually by:
- create the app folder structure,
- place your script into:
MyApp.app/Contents/MacOS/MyApp.app
- make the file executable
In other words (Gino):
- Create your shell script (ex
command.sh
)
- Give it execution permissions (
chmod 755 ./command.sh
)
- Get Info → Open with: → (associate the Terminal app)
- Get Info → (put the icon you want on it)
See also: