← 返回命令列表

Linux command

terminal-notifier 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Send a basic notification

terminal-notifier -message "[Task completed]"

Send with title and subtitle

terminal-notifier -title "[Build]" -subtitle "[Success]" -message "[All tests passed]"

Send with a sound

terminal-notifier -message "[Done]" -sound default

Send and open URL on click

terminal-notifier -message "[New issue]" -open "[https://github.com]"

Send and activate an app on click

terminal-notifier -message "[Sync complete]" -activate [com.apple.AddressBook]

Send from piped input

echo "[Build finished]" | terminal-notifier

Group notifications

terminal-notifier -group "[build]" -message "[Completed]"

说明

terminal-notifier sends macOS User Notifications from the command line. It enables scripts and terminal commands to display native system notifications with customizable content, sounds, and click actions. Notifications can include titles, subtitles, message bodies, and sounds. Click actions can open URLs, activate applications, or execute callbacks. Group identifiers allow replacing previous notifications instead of stacking them. The tool is useful for alerting when long-running processes complete, such as builds, downloads, or scheduled tasks.

参数

-message _text_
The notification message body (required unless piping)
-title _text_
The notification title (default: "Terminal")
-subtitle _text_
The notification subtitle
-sound _name_
Play a sound from /System/Library/Sounds; use "default" for system default
-group _id_
Group identifier; only one notification per group shown at a time
-activate _bundleid_
Activate specified app when notification is clicked
-open _url_
Open URL when notification is clicked
-remove _id_
Remove notification with specified group ID
-list _id_
List notifications with specified group ID

FAQ

What is the terminal-notifier command used for?

terminal-notifier sends macOS User Notifications from the command line. It enables scripts and terminal commands to display native system notifications with customizable content, sounds, and click actions. Notifications can include titles, subtitles, message bodies, and sounds. Click actions can open URLs, activate applications, or execute callbacks. Group identifiers allow replacing previous notifications instead of stacking them. The tool is useful for alerting when long-running processes complete, such as builds, downloads, or scheduled tasks.

How do I run a basic terminal-notifier example?

Run `terminal-notifier -message "[Task completed]"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -message _text_ do in terminal-notifier?

The notification message body (required unless piping)