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?
4 Answers
Use Automator.
- Open Automator and double-click on Application.
- In the "Name" search box, type Apple and you should see "Run AppleScript".
- Drag "Run AppleScript" into the right-hand window.
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
- File > Save and enter a name, and choose where to save the application.
- Double-click on the newly created application.
Short answer:
do shell script "/your/script/path/shellscript.sh"
Use this snippet in an AppleScript, then save it as an application.
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
-
1Worked like a charm for me, thanks! I used it to create an app for git-cola in a different way than the original approach– WojtekCommented Jan 24 at 11:48
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.