主题
Claude Code CLI 在 Windows 和 macOS 下的桌面通知提醒配置 —— 通过修改 ~/.claude/settings.json 中的 hooks 实现任务完成和等待输入时的桌面弹窗。Windows 用 BurntToast(含 4 种 Logo 方案),macOS 用 osascript 或 terminal-notifier。
配置文件位置
- Windows:
C:\Users\<你的用户名>\.claude\settings.json - macOS:
~/.claude/settings.json
Hook 类型说明
| Hook 类型 | 触发场景 | 示例作用 |
|---|---|---|
Stop | Claude 完成输出 | 弹通知"任务完成" |
Notification | Claude 等待用户输入 / AskUserQuestion | 弹通知"等待你的输入" |
macOS 配置
方案 1:osascript(系统内置,无需安装)
json
{
"hooks": {
"Stop": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"任务完成\" with title \"Claude\"'"
}
]
}
],
"Notification": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"等待你的输入\" with title \"Claude\"'"
}
]
}
]
}
}特点: 零依赖,系统内置,直接可用。
方案 2:terminal-notifier(更丰富的通知)
安装:
bash
brew install terminal-notifier配置:
json
{
"hooks": {
"Stop": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "terminal-notifier -title 'Claude' -message '任务完成' -sound default"
}
]
}
],
"Notification": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "terminal-notifier -title 'Claude' -message '等待你的输入' -sound default"
}
]
}
]
}
}特点: 支持自定义图标、声音、按钮,可指定 -appIcon 使用 Claude 图标。
方案 3:Emoji 标题区分(macOS 推荐)
json
{
"hooks": {
"Stop": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"任务完成\" with title \"🤖 Claude\"'"
}
]
}
],
"Notification": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"等待你的输入\" with title \"❓ Claude\"'"
}
]
}
]
}
}Windows 配置
前置条件: 安装 BurntToast PowerShell 模块。
基础配置
json
{
"hooks": {
"Stop": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "powershell -Command \"Import-Module BurntToast; New-BurntToastNotification -Text 'Claude','任务完成'\""
}
]
}
],
"Notification": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "powershell -Command \"Import-Module BurntToast; New-BurntToastNotification -Text 'Claude','等待你的输入'\""
}
]
}
]
}
}声音提示增强: 可在命令中加入 [System.Media.SystemSounds]::Asterisk.Play() 实现通知 + 声音。
Logo 自定义方案
方案 1:BurntToast 默认通知(最简单)
powershell
New-BurntToastNotification -Text "Claude", "任务完成"Logo 显示为 PowerShell 图标 / Terminal 图标 / 应用宿主图标,不可修改。
方案 2:指定自定义 PNG
准备 Logo 文件 C:\Tools\claude\claude.png:
powershell
$img = New-BTImage -Source "C:\Tools\claude\claude.png"
New-BurntToastNotification -Text "Claude","任务完成" -AppLogo $imgHook 配置:
json
{
"hooks": {
"Stop": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "powershell -Command \"$img=New-BTImage -Source 'C:\\Tools\\claude\\claude.png'; New-BurntToastNotification -Text 'Claude','任务完成' -AppLogo $img\""
}
]
}
]
}
}方案 3:Claude 官方 Logo
下载 Claude Logo 保存为 C:\Tools\claude\claude.png,用法同方案 2。
方案 4:Emoji 标题区分(Windows 推荐)
不依赖 Logo,直接在通知标题中用 Emoji 区分场景:
powershell
New-BurntToastNotification -Text "🤖 Claude","任务完成"
New-BurntToastNotification -Text "❓ Claude","等待你的回复"
New-BurntToastNotification -Text "🚨 Claude","需要确认操作"推荐理由: 配置简单、视觉区分度足够、无需额外文件依赖、不易出错。