Home Interests Mac

How to Display macOS Notifications from the Command Line

howchoo
howchoo   (436)
November 24, 2023
3 minutes

Share

Interests
Posted in these interests:
 
apple • 17 guides

Mac

mac • 22 guides

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.

1 – Use the “display” AppleScript command

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!

NEXT UP

How to Block a Website with Screen Time on Your iPhone

Block inappropriate or spammy websites with screen time!
howchoo   (436)
November 30, 2023

Screen time gives iPhone users the opportunity to track and manage their iPhone usage, making staying productive easier than ever before. Since screen time holds iPhone users accountable for their iPhone use, it’s become increasingly popular among those who want and need to unplug during various time frames. However, that’s not all screen time is capable

Continue Reading

howchoo

 436 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo's writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Discover interesting things!

Explore Howchoo's most popular interests.

Explore