一个用于 macOS 的终端通知工具,支持 Claude Code 的消息通知功能,同时提供丰富的自定义选项。
- 📱 支持 macOS 原生通知系统
- 🔔 Claude Code 集成通知功能
- 🎨 自定义图标、声音和内容
- 🔗 点击通知可打开链接或应用程序
- 📊 支持通知分组和管理
- 🌐 支持多语言(中文/英文)
terminal-notifier
: Shell 脚本封装器,可放置在/usr/local/bin
或~/bin
等可执行目录terminal-notifier-2.0.0.zip
: 原生 macOS 应用程序
# 解压并安装到应用程序目录
unzip terminal-notifier-2.0.0.zip
cp -r terminal-notifier.app /Applications/
# 复制到系统路径
chmod +x terminal-notifier
sudo cp terminal-notifier /usr/local/bin/
# 将 commands 文件夹复制到 Claude 目录
cp -r commands ./claude/
# 启动 Claude Code
./claude
# 选择 /claude-notifier 命令
# 选择 enable/disable 来开启/关闭通知
效果展示
- 唤起助手
- 启动完毕
- 通知展示
terminal-notifier -message "Hello World" -title "通知"
echo "管道消息" | terminal-notifier -sound default
# 自定义图标
terminal-notifier -title "项目" -subtitle "新标签" -message "完成" -appIcon ./icon.png
# 打开链接
terminal-notifier -title "📈" -message "查看股价!" -open "https://finance.yahoo.com"
# 激活应用
terminal-notifier -group "sync" -title "同步完成" -activate "com.apple.Terminal"
选项 | 说明 |
---|---|
-message VALUE |
通知消息内容 |
-remove ID |
移除指定组的通知 |
-list ID |
列出指定组的通知详情 |
选项 | 说明 | 示例 |
---|---|---|
-title VALUE |
通知标题 | -title "重要通知" |
-subtitle VALUE |
通知副标题 | -subtitle "系统消息" |
-sound NAME |
通知声音 | -sound default |
-group ID |
通知组 ID | -group "build-123" |
-activate ID |
点击时激活应用 | -activate "com.apple.Terminal" |
-sender ID |
模拟发送应用 | -sender "com.apple.Safari" |
-appIcon PATH |
自定义图标 | -appIcon "./icon.png" |
-contentImage PATH |
通知内容图片 | -contentImage "./image.png" |
-open URL |
点击时打开链接 | -open "https://example.com" |
-execute COMMAND |
点击时执行命令 | -execute "open -a Terminal" |
-ignoreDnD |
忽略勿扰模式 | -ignoreDnD |
terminal-notifier -message "构建完成!" -title "CI/CD"
echo "任务完成" | terminal-notifier -sound default -title "通知"
terminal-notifier -title "ProjectX" -subtitle "新版本" -message "发布成功" -appIcon "./logo.png"
terminal-notifier -title "📧" -message "新邮件到达" -open "https://mail.google.com"
terminal-notifier -group "build-process" -title "构建中" -message "步骤 1/3"
该工具是一个 Shell 脚本封装器,将命令参数转发给原生的 terminal-notifier
应用程序:
#!/bin/bash
ORIGINAL_TERMINAL_NOTIFIER="/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier"
if [ -x "$ORIGINAL_TERMINAL_NOTIFIER" ]; then
"$ORIGINAL_TERMINAL_NOTIFIER" "$@"
else
echo "原始 terminal-notifier 未找到: $ORIGINAL_TERMINAL_NOTIFIER"
fi
- 通知样式: 如需通知保持显示直到用户关闭,请在系统偏好设置 → 通知 → terminal-notifier 中将样式从"横幅"更改为"警报"
- 权限: 确保脚本有执行权限 (
chmod +x terminal-notifier
) - 路径: 确保原生应用安装在
/Applications/terminal-notifier.app/
- 声音: 可用声音文件位于
/System/Library/Sounds/
欢迎提交 Issue 和 Pull Request!
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。
基于 terminal-notifier 项目开发。