How to get a Mac notification when a Terminal command finishes
To get a notification when a long Terminal command finishes, put a second command after it. make; say "Done" speaks when the build ends, and osascript -e 'display notification "Done"' shows a banner. Both come with macOS, so there's nothing to install.
Here are the built-in ways, how to hear whether the command worked or failed, and two free tools that do more. I checked them against Apple's guides and the manual pages on macOS 27, and Apple gives the same Terminal steps for macOS 14 Sonoma.
Show a notification with osascript
osascript runs a line of AppleScript, and AppleScript's display notification command shows a banner:
osascript -e 'display notification "The build is done" with title "Terminal" sound name "Glass"'
The message is the only part you need. The title, a subtitle and the sound are optional, as Apple's Mac Automation Scripting Guide shows. Apple's example uses Frog, one of the system sounds in /System/Library/Sounds; the others there are Basso, Blow, Bottle, Funk, Glass, Hero, Morse, Ping, Pop, Purr, Sosumi, Submarine and Tink.
How the banner looks, and whether it gets through during a Focus, is set in Apple menu › System Settings › Notifications, the same path from macOS 14 to macOS 27 (Apple's guide).
If no banner appears
Apple's scripting guide, last updated in 2016, says a script that shows a notification is added to the apps in Notifications settings, or Script Editor is when the script runs there. On recent versions of macOS, people in scripting forums report that the line runs without an error but nothing appears until Script Editor is allowed to notify. The fix they describe: open Script Editor (in Applications › Utilities), type display notification "Test" in a new document, run it once and allow notifications when macOS asks. Then check that Script Editor is turned on in Notifications settings, and that no Focus is on. One post on Apple's developer forums says it stopped working after an update to macOS Tahoe, and it has no answer yet.
If yours stays silent, the next two ways don't depend on Notifications settings at all.
Hear it: say or a system sound
say "Build finished"
afplay /System/Library/Sounds/Glass.aiff
say reads the text out loud in your Mac's system voice, and say -v '?' lists the other voices. afplay plays an audio file, here one of the system sounds, and its -v option sets the volume. Both are described in their manual pages (man say, man afplay).
A sound is the better choice when you've walked away from the screen, since a banner can come and go while you're not looking.
Ring the terminal bell
printf '\a'
This writes the bell character, and Terminal decides what happens. Choose Terminal › Settings, click Profiles, select your profile, then click Advanced. Under Bell, Apple's Terminal User Guide lists these:
- Audible bell, which plays a sound
- Visual bell, which flashes the window
- Only when sound is muted, which flashes instead while your sound is off
- Badge app and window Dock icons, which counts the background sessions that rang
- Bounce the app icon when in the background, and Continue bouncing until in foreground
The badge and the bounce are the useful ones here. Run long-command; printf '\a' in a tab, switch to another app, and the Dock icon tells you when it's done. These settings belong to the profile you select, so set them in the one your windows use.
Chain it after a long command
How you join the two commands decides when the alert comes:
long-command; say "Done"speaks whatever happenedlong-command && say "Done"speaks only if it workedlong-command || say "Failed"speaks only if it failed
Or both at once: make && say "Build done" || say "Build failed".
If the command is already running, press Control-Z to pause it, then type fg; say "Done". fg carries on with it where it stopped, and say runs when it ends.
For something you'll use every day, add a small function to the file ~/.zshrc:
notify() { "$@"; local code=$?; osascript -e "display notification \"Exit code $code\" with title \"$1 finished\""; return $code; }
Open a new Terminal window, then put notify in front of any command, as in notify make. When it ends, the banner says which command finished and its exit code, where 0 means it worked.
If a job runs for hours, keep the Mac from going to sleep halfway too: see how to keep your Mac awake.
terminal-notifier and iTerm2
terminal-notifier is a free, open source (MIT) tool for sending notifications from the command line. Version 3.0 came out in August 2026, its first release in nine years, rebuilt on Apple's current notification framework, and 3.1 followed the same month. It needs macOS 10.14 or later and runs natively on Apple silicon and Intel. Install it with brew install terminal-notifier, then:
make; terminal-notifier -title "Build" -message "Finished" -sound default
A click on the notification can open a web address or run a command (-open, -execute), and terminal-notifier -diagnose reports why notifications aren't appearing. The copy on its releases page isn't notarized and needs a Terminal command before it opens; installed with Homebrew, it doesn't.
iTerm2, a free terminal app (GPL v2; version 3.7.9 needs macOS 13 or later), has two features for this. With its shell integration installed (iTerm2 › Install Shell Integration), start a command and choose Edit › Marks and Annotations › Alert on next mark, or press Command-Option-A: an alert appears when the prompt comes back. And in iTerm2 › Settings › Profiles › Terminal, Notification Center alerts posts a notification when a session rings the bell, goes idle or closes, with Filter Alerts to choose which. With that on, the printf '\a' above can arrive as a notification too. Details are in its shell integration guide and profile settings.
For coding assistants
Most command-line coding assistants can run a command of your choice when they finish or stop to ask you something, usually from a hooks or notifications setting. Point that setting at one of the lines above, such as say "Your assistant needs you" or the osascript line, and you'll hear about it without keeping the terminal in view. Each assistant puts the setting in a different place, so check its own documentation.
In the notch, with Lunille
I make Lunille, a notch app for the Mac, and these alerts are one of the things it shows. Command-line coding assistants that keep session logs on your Mac are picked up with nothing to set up: when one finishes or needs you, a card comes up in the notch with the first lines of its answer. More of them connect with a switch in Settings › AI Assistants.
Your own scripts can use the notch too, through lunille:// links:
make && open "lunille://peek?title=Build%20finished&value=12s&symbol=hammer.fill&tint=green"
Keep the quotes, because of the & signs. The title is the only part you need:
titleis the text, up to 40 characters, with%20for each spacevalueis a short extra of up to 24 characters, shown on the other side of the notchsymbolis an SF Symbols name, and one your Mac doesn't have shows a bell insteadtintis a colour name such as green, orange, red or blue, or six hex digits such as FF9500
open "lunille://timer?minutes=25" starts a timer the same way.
If all you need is to know when one command ends, say or the bell does it for free. Lunille makes more sense if you'd use the rest of the notch: your music with synced lyrics, your next meeting with a Join button, a file tray and clipboard history, and Luni, the little moon who lives in the notch and cheers when your coding assistant is done.
Lunille runs on macOS 14 or later, on Apple silicon and Intel, and on Macs without a notch it shows as a small pill at the top of the screen. It's a one-time purchase for up to 3 Macs, with a 14-day free trial that needs no account, at lunille.com.