8

I have a command line executable (specifically JMeter), which opens a GUI application when launched from the terminal. However, I would like to create a link to it that would wrap it up to become a proper Mac application (included in /Applications directory and all that). How do I do that?

0

4 Answers 4

9

Use Automator.

  1. Open Automator and double-click on Application.
  2. In the "Name" search box, type Apple and you should see "Run AppleScript".
  3. Drag "Run AppleScript" into the right-hand window.
  4. Where it says (* Your script goes here *), replace that text with the following code:

    tell application "Terminal"
        activate
        do script with command "JMeter"
    end tell
    
  5. File > Save and enter a name, and choose where to save the application.
  6. Double-click on the newly created application.
5

Short answer:

do shell script "/your/script/path/shellscript.sh"

Use this snippet in an AppleScript, then save it as an application.

4

The answer that uses Automator worked for me to wrap GNumeric, but it was opening an ugly Terminal box and I could not close it without closing GNumeric, so I was able to get rid of it by changing it as follows:

tell application "/usr/local/bin/gnumeric"
    activate
end tell
1
  • 1
    Worked like a charm for me, thanks! I used it to create an app for git-cola in a different way than the original approach
    – Wojtek
    Commented Jan 24 at 11:48
2

Here are the commands to create a minimum version of the app which runs top command:

APP=Foo
mkdir -vp ${APP}.app/Contents/MacOS ${APP}.app/Contents/Resources # Create the folders.
PATH="$PATH:/usr/libexec" # Make sure PlistBuddy is in the PATH.
printf '#!/usr/bin/osascript\ntell application "Terminal"\n\tactivate\n\tdo script "top"\nend tell\n' > ${APP}.app/Contents/MacOS/${APP}
chmod +x ${APP}.app/Contents/MacOS/${APP} # Sets the executable flag.
PlistBuddy ${APP}.app/Contents/Info.plist -c "add CFBundleDisplayName string ${APP}"
PlistBuddy ${APP}.app/Contents/version.plist -c "add ProjectName string ${APP}"
find ${APP}.app # Verify the files.
open ${APP}.app # Run the app.

Note: The above commands should be executed in shell e.g. in Terminal.

In above code, you can replace top with your shell command.


In case, you're dealing with Windows apps, consider using WineBottler app.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .