Shell script Mac OS X App : get its path
DIR=$(cd "$(dirname "$0")"; pwd)
will give the shell script's directory name. For a shell script app, this will be /path/to/Your shell script application.app/Contents/MacOS
.
I was suggesting to try which
, but it doesn't work for Mac applications.
You can use find, keeping in mind that Mac applications are bundled, and a shell sees them as directory. Don't forget to add the extension for applications (.app).
If you can get the application's absolute path to the executable, getting the bundle dir is as simple as appending that with /../.. that gets you the main bundle. If you want the resources however, just add to the above /Resources.