How to show a Mac notification after a Terminal task

Use the built-in osascript command for a simple completion notification, keep private command output out of the message and check notification permissions.

You can ask macOS to display a simple notification from Terminal using osascript. Whether it appears or sounds depends on notification settings, Focus and the app macOS attributes it to.

Test a fixed message

Run a harmless notification before attaching it to important work:

osascript -e 'display notification "The task has finished." with title "Terminal task"'

Use a fixed message like this rather than interpolating command output into AppleScript. Logs can contain private paths or secrets, and shell quoting mistakes can turn data into code.

Attach it to the intended outcome

For an interactive success-only message, place the notification after your known command with &&. If you want different results for failure, save the original status first and handle the two cases explicitly.

A notification failure should not disguise the task’s outcome. See preserving command status before turning a one-line experiment into a reusable script.

Check delivery without flooding it

Look in notification settings for the sender identified by macOS and inspect your current Focus mode. A missing banner can be a presentation rule rather than proof the command never ran.

This sends a local macOS notification; it is not an email or a push message to another device. For a simple audible cue, afplay uses the selected local audio path. TapNoise’s agent cues provide another option for supported local agents.

Sources: macOS man osascript; Apple’s Terminal guide.

About the author

Rudra Satani makes TapNoise. Spotted a mistake? Email support@tapnoise.com, or reach out at @rudraxx13.

Hear TapNoise on your Mac

Every sound is made by TapNoise itself. Try the sounds on the homepage first, then download the app.