When scripting or automating stuff for macOS, using shell scripts come in handy – these are scripts than can be run from the «Terminal.app» and are quite powerful thanks to the underlying Unix core. I stumbled upon the command line program «osascript
» recently, which is capable of running Apple’s AppleScript-code – bringing even more Mac power to Terminal scripts.
Let’s try it!
Send Notification Center alerts from Terminal
One particular AppleScript-based feature that I find helpful for scripts running in the Terminal, is to send notifications to the macOS Notification Center. So a script can run while the user continues doing other things – and a prominent Notification pops up when needed.
Here’s the code to trigger a custom macOS Notification using «osascript»
As mentioned the underlying script language used for this is AppleScript, so this command might look a bit uncommon.
macOS Notification variations & parts
Anatomy of a macOS Notification
By adjusting the osascript
instruction, you can populate and set the following parts of a Notification message. The [Notification text]
part is required.
+-----------------------------------------(x) | [Title] | | [Subtitle] | |------------------------------------------| | [Notification text] | +------------------------------------------+
Note: I found it sometimes struggles with special characters in different parts, so make sure to test properly.
More examples
Here are some variations and examples for differently populated custom macOS Notifications:
- Notification Title and Text
- Notification Title, Subtitle, and Text
- And here’s a more advanced bash script-functionality
Enable/Disable and style the custom Notifications
You can control these Notifications behaviour and look+feel through the Application Notification identifier «Script Editor» via System Settings » Notifications.

Sources used
- Inspired through the «vladzima/mac-cpu-monitor» shell script
- AppleScript guide on «Displaying Notifications»
- The «osascript» CLI program man page