2

My goal is to execute a shell script by double clicking on an OS X .app, and the Terminal to be visible to the user (my script has a CLI GUI).

Any ideas? I've tried appify but I can't get it to show the Terminal window. Many thanks.

DavidD
  • 1,009
  • 1
  • 14
  • 29

1 Answers1

4

For those interested, I found the following solution which involves using an Apple Script command.

First you need to create a launcher.sh script. Use the code below. The many quotes below allow your app to run from a path with spaces.

#!/bin/bash
scriptPath=$(dirname "$0")'/yourscript.sh'
osascript -e 'tell app "Terminal" to do script "\"'"$scriptPath"'\""'

Use appify to generate an app bundle. Type this in the Terminal to do it:

appify launcher.sh "Your app name"

From Finder, right-click on your generated app bundle, Show package contents, and paste yourscript.sh into /Contents/MacOS/

DavidD
  • 1,009
  • 1
  • 14
  • 29