Mac App From Bash Script
/Applications/Utilities/Automator.app With it you can easily package a bash script into an app, accepting file names. Look for an action called 'Run Shell Script'. Thus, I find it frustrating that Mac OS X includes no easy way to quit an application politely (allowing the app to save data, clean up after itself, etc.) from the command line. There are command line options that are easy to use, but not nice to applications, and an option that is nice to applications, but not easy to use.
If you ever need to close a Mac OS X application (gracefully) from the Mac Terminal command line or from a shell script, I can confirm that this command works: osascript -e 'quit app 'Safari' I use that command from a Mac/Unix shell script to close the Safari browser in an automation script I’m writing, and it works fine.
Platypus is a developer tool that creates native Mac applications from command line scripts such as shell scripts or Python, Perl, Ruby, Tcl, JavaScript and PHP programs. This is done by wrapping the script in a macOS application bundle along with an app binary that runs the script.
Platypus makes it easy to share scripts and programs with people who are unfamiliar with the command line interface. Native, user-friendly applications can be created with a few clicks. It is very easy to create installers, droplets, administrative applications, login items, status menu items, launchers and automations using Platypus.
Features
- Supports shell scripts, Python, Perl, Ruby, PHP, Swift, Expect, Tcl, AWK, JavaScript, AppleScript or any other user-specified interpreter
- Apps can display graphical feedback of script execution as progress bar, text window with script output, droplet, WebKit HTML rendering or status item menu
- Apps support receiving dragged and dropped files or text snippets, which are then passed to the script as arguments
- Apps can execute scripts with root privileges via the macOS Security Framework
- Apps can register as handlers for URI schemes
- Apps can be configured to run in the background (LSUIElement)
- Set own application icon or select from presets
- Set app's associated file types, identifier, version, author, etc.
- Graphical interface for bundling support files with the script
- Command line tool for automation and build process integration
- 'Profiles' can be used to save app configurations
- Built-in script editor, or linking with external editor of choice
- Extensive documentation and many built-in examples to help you get started
- Fast, responsive native app written in Objective-C/Cocoa
License
Platypus is free, open source software distributed under the terms of the three-clause BSD license and has been continually maintained and developed for a very long time (since 2003). It is written in Objective-C/Cocoa. The source code is available on GitHub.
If Platypus makes your life easier, please make a donation to support continued development.
Download
Mac App From Bash Scripts
The latest version is Platypus 5.3, released on November 25th, 2018. Platypus and Platypus-generated applications require macOS 10.8 or later, and are 64-bit Intel binaries. The main Platypus application is Apple Developer ID signed (sigh)...
If you want to target 10.6 and/or 32-bit systems, version 4.9 continues to work just fine. If you want to target 10.4 and PowerPC, you can use version 4.4.
- man page (HTML)
- Appcast (XML)
Screenshots
Platypus lets you select one of several different user interfaces for your script.
Progress Bar
Text Window
Web View
Mac Install Bash
Status Menu
Droplet
About Mac Scripting
Scripting allows you to automate complex, repetitive, and time-consuming tasks by writing scripts that interact with apps, processes, and the operating system. A script consists of a series of statements, each of which performs a specific operation. These statements work together to automate tasks. Through scripting, you can create powerful workflow solutions that enhance productivity, reduce errors, save time, and save money.
There are many different scripting languages. On the Mac, the primary ones used for automation are AppleScript and JavaScript.
Note
OS X also includes Automator, an app for building workflows that run prebuilt, configurable actions to perform tasks in apps and throughout the operating system. Automator doesn’t require you to write any code, but can be extended through scripting. Because Automator uses preconceived actions and operates in a linear manner, it’s more limited in functionality than scripting. Automator is great for performing simple tasks involving a small number of sequential steps or apps. Scripting is a better choice for performing advanced, branching, or complex tasks.
Python and Perl are other examples of scripting languages.
AppleScript
AppleScript is a mature scripting language developed by Apple. It’s relatively easy to learn in relation to other scripting and programming languages, has been around since System 7.1, and has been widely adopted in both enterprise and personal workflows. While the AppleScript scripting language uses an English-like terminology which may appear simple, it is a rich, object-oriented language, capable of performing complicated programming tasks.
The core fundamentals of AppleScript are described in AppleScript Language Guide, as well as in numerous third-party books.
JavaScript
JavaScript is a popular cross-platform scripting language. Historically, it’s been most commonly used to implement features on websites and in web-based apps that are accessed through browsers. However, some apps implement JavaScript-based scripting models for the purpose of automation. In OS X 10.10, JavaScript became a peer to AppleScript in OS X. There are many third-party websites and books that document the JavaScript language.
For fundamentals on JavaScript as a scripting language for automation in OS X, see JavaScript for Automation Release Notes. For information about the JavaScript language, see Mozilla’s official JavaScript documentation.
Copyright © 2018 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2016-06-13