How to Display macOS Notifications from the Command Line

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

In this guide, we’re going to use AppleScript and a tool called osascript to display macOS notifications. AppleScript is a scripting language created by Apple that allows us to automate control of Mac applications, and osascript is a tool that allows us to execute AppleScript from the command line.

With these tools, we can easily display macOS notifications from the command line or from within shell scripts.

Posted in these interests:

mac
PRIMARY
81 guides
apple
51 guides

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

How to Display macOS Notifications from the Command Line

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

In this guide, we’re going to use AppleScript and a tool called osascript to display macOS notifications. AppleScript is a scripting language created by Apple that allows us to automate control of Mac applications, and osascript is a tool that allows us to execute AppleScript from the command line.

With these tools, we can easily display macOS notifications from the command line or from within shell scripts.

Posted in these interests:

mac
PRIMARY
81 guides
apple
51 guides

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

How to Display macOS Notifications from the Command Line

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

In this guide, we’re going to use AppleScript and a tool called osascript to display macOS notifications. AppleScript is a scripting language created by Apple that allows us to automate control of Mac applications, and osascript is a tool that allows us to execute AppleScript from the command line.

With these tools, we can easily display macOS notifications from the command line or from within shell scripts.

Posted in these interests:

mac
PRIMARY
81 guides
apple
51 guides

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

How to Display macOS Notifications from the Command Line

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

In this guide, we’re going to use AppleScript and a tool called osascript to display macOS notifications. AppleScript is a scripting language created by Apple that allows us to automate control of Mac applications, and osascript is a tool that allows us to execute AppleScript from the command line.

With these tools, we can easily display macOS notifications from the command line or from within shell scripts.

Posted in these interests:

mac
PRIMARY
81 guides
apple
51 guides

How to Display macOS Notifications from the Command Line

macapple
Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020
Tyler
2
 

Posted in these interests:

mac
PRIMARY
81 guides
apple
51 guides
mac
PRIMARY
81 guides
apple
51 guides
PRIMARY
Calling all writers!

We’re hiring. Write for Howchoo

2
 
In these interests
mac
PRIMARY
81 guides
apple
51 guides
mac
PRIMARY
81 guides
apple
51 guides
PRIMARY

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

Use the “display” AppleScript command

Calling all writers!

We’re hiring. Write for Howchoo

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Tyler's profile picture
Share this guide!
RedditEmailText
Related to this guide:
How to Convert HEIC files to JPGHow to Convert HEIC files to JPG
Now when you airdrop photos from your phone, you can easily convert them to JPGs.
Michael's profile picture MichaelView
In these interests: osxmac
Screen Shot of Image Properties ScreenScreen Shot of Image Properties Screen
Before you lose years converting those PNG files to JPGs.
Michael's profile picture MichaelView
In these interests: macosmac
Reset Network Settings MacOSReset Network Settings MacOS
Trouble with Wi-Fi? Don’t forget to try this.
Ash's profile picture AshView
In these interests: networkingapplemac
How to Convert HEIC files to JPGHow to Convert HEIC files to JPG
Now when you airdrop photos from your phone, you can easily convert them to JPGs.
Michael's profile picture MichaelView
In these interests: osxmac
Michael's profile pictureViewosxmac
Screen Shot of Image Properties ScreenScreen Shot of Image Properties Screen
Before you lose years converting those PNG files to JPGs.
Michael's profile picture MichaelView
In these interests: macosmac
Michael's profile pictureViewmacosmac
Reset Network Settings MacOSReset Network Settings MacOS
Trouble with Wi-Fi? Don’t forget to try this.
Ash's profile picture AshView
In these interests: networkingapplemac
Ash's profile pictureViewnetworkingapplemac
People also read:
Force your Mac to use the Ethernet/wired connection when it’s connected.
MacBook
Strange Mac issue? One of these will probably fix it.
An Apple keyboard on a desk showing fn and control keys
If you’re used to CTRL being the bottom left key, this guide will help you.
“I wish my MacOS apps could tap me on the shoulder until I answer.” – No one ever
MacBook Pro Keyboard showing Control Strip
The Touch Bar is a neat addition to the MacBook Pro. For me, however, it’s kind of annoying and I just want my normal Control Strip back rather than application-specific options.
Tired of Zoom’s security issues? Get rid of it.
Connect your favorite Bluetooth device.
Uninstall software from macOS.
You clean up your desk, why not your desktop?
Every time I go to empty my Mac’s trash, I have to click yet another dialog box to confirm. I find this a tad annoying, but thankfully this is an option we can control.
Force your Mac to use the Ethernet/wired connection when it’s connected.
MacBook
Strange Mac issue? One of these will probably fix it.
An Apple keyboard on a desk showing fn and control keys
If you’re used to CTRL being the bottom left key, this guide will help you.
“I wish my MacOS apps could tap me on the shoulder until I answer.” – No one ever
How to Prioritize Ethernet Over Wi-Fi in macOS
MacBook
MacBookHow to Reset Your Mac’s PRAM, SMC, and NVRAM (and Why)
Mac keyboard symbols
Mac keyboard symbolsMac Keyboard Symbol Reference Guide
An Apple keyboard on a desk showing fn and control keys
An Apple keyboard on a desk showing fn and control keysHow to Remap the fn (Function) key to ctrl (Control) on Mac
How to Disable the Mac Dock Icon Bouncing Behavior
MacBook Pro Keyboard showing Control Strip
The Touch Bar is a neat addition to the MacBook Pro. For me, however, it’s kind of annoying and I just want my normal Control Strip back rather than application-specific options.
Tired of Zoom’s security issues? Get rid of it.
Connect your favorite Bluetooth device.
Uninstall software from macOS.
You clean up your desk, why not your desktop?
Every time I go to empty my Mac’s trash, I have to click yet another dialog box to confirm. I find this a tad annoying, but thankfully this is an option we can control.
MacBook Pro Keyboard showing Control Strip
MacBook Pro Keyboard showing Control StripHow to Disable the MacBook Pro Touch Bar
How to Fully Uninstall Zoom from your Mac
How to Turn on Bluetooth in macOS
Uninstall software from macOS.
Uninstall software from macOS.How to Uninstall Software on Mac
How to Disable the Mac Empty Trash Warning (macOS and OS X)
Posted in these interests:
macmac
mac
PRIMARY
appleapple
Apple Computers is an American computer and consumer electronics company founded by Steve Jobs and Steve Wozniak.
macmac
mac
PRIMARY
PRIMARY
Explore
appleapple
Apple Computers is an American computer and consumer electronics company founded by Steve Jobs and Steve Wozniak.
Explore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate

Leave a Reply

Your email address will not be published. Required fields are marked *