通知功能
Aider 可以在等待用户输入时发送桌面通知。当您离开终端去做其他事情时,这个功能特别有用。
启用通知
要启用通知功能,请在启动 aider 时添加 --notify
标志:
aider --notify
或者,您可以在 配置文件 中设置 notify
选项为 true
:
notify: true
工作原理
当 Aider 需要用户输入时(例如在 >
提示符处),它会发送一个桌面通知。这包括以下情况:
- 当 Aider 启动并准备接收您的第一个命令时
- 当 Aider 完成代码生成或编辑后等待下一步指示时
- 当 Aider 遇到错误需要您注意时
依赖要求
通知功能需要安装 plyer
包。如果您在运行 --notify
时看到错误提示,请安装该包:
pip install plyer
自定义通知
您可以通过修改 plyer
的配置来自定义通知行为。例如,在某些平台上,您可能需要配置特定的通知后端。
禁用通知
要临时禁用通知,只需不添加 --notify
标志运行 Aider。要永久禁用,请从配置文件中移除 notify
设置或将其设为 false
。
notify: false
通知功能
Aider 可以在完成工作等待您输入时发送通知。 这对于长时间运行的操作或多任务处理特别有用。
使用方式
通过 --notifications
参数启用通知功能:
aider --notifications
启用后,当 LLM 完成响应生成并等待您的输入时,aider 会通知您。
操作系统特定通知
Aider 会自动检测您的操作系统并使用适当的通知方式:
- macOS:如果可用则使用
terminal-notifier
,否则回退到 AppleScript 通知 - Linux:如果可用则使用
notify-send
或zenity
- Windows:使用 PowerShell 显示消息框
自定义通知命令
您可以通过 --notifications-command
指定自定义通知命令:
aider --notifications-command "your-custom-command"
例如,在 macOS 上您可以使用:
aider --notifications-command "say 'Aider is ready'"
远程通知
要实现远程通知,您可以使用 Apprise, 这是一个跨平台的 Python 库,可以向各种服务发送通知。
我们可以使用 Apprise 向 Slack 发送通知:
aider --notifications-command "apprise -b 'Aider is ready' 'slack://your-slack-webhook-token'"
或 Discord:
aider --notifications-command "apprise -b 'Aider is ready' 'discord://your-discord-webhook-token'"
甚至通过 Pushbullet 发送到您的手机:
aider --notifications-command "apprise -b 'Aider is ready' 'pbul://your-pushbullet-access-token'"
更多关于 Apprise 的使用和配置方法,请查看其 GitHub 页面。
配置
您可以将这些设置添加到配置文件中:
# 启用通知
notifications: true
可选的自定义通知命令
notifications_command: “your-custom-command”
或者在 `.env` 文件中配置:
AIDER_NOTIFICATIONS=true AIDER_NOTIFICATIONS_COMMAND=your-custom-command ```