Terminal notifications

Generate a macOS notification or terminal bell for a long-running shell task. Customise the message and copy the command.

Shell command

Use this command in a macOS shell.

/usr/bin/osascript -e 'on run argv' -e 'display notification (item 2 of argv) with title (item 1 of argv)' -e 'end run' -- 'Terminal' 'Task complete'

Get a notification when a terminal task finishes

Use a macOS notification for a named alert, or a terminal bell for a signal controlled by your terminal settings. The generated snippet is intended for a Mac shell.

Append the snippet to a shell task with && to notify on success, or after a semicolon to notify once the task exits. Focus and Notifications settings affect whether a macOS alert is visible.

You can also wrap the command in a short shell alias such as notify-done so any long build, migration or test suite alerts you without retyping the osascript call.

Common questions

Why did my macOS notification banner not appear?

Check System Settings → Notifications → Script Editor (or your terminal app) and ensure Focus or Do Not Disturb is not silencing banners.

What is the difference between using && and ; before the command?

Using && triggers the notification only if the preceding command succeeds with exit code 0, whereas ; runs the notification regardless of whether the job passed or failed.