English | 中文
This configuration demonstrates how to send desktop notifications through ghostty terminal when Claude Code tasks are completed. Claude Code supports a hooks mechanism that can execute custom commands when specific events occur.
Open or create Claude Code's configuration file:
vim ~/.claude/settings.jsonAdd the following content to the hooks section of the configuration file:
{
"hooks": {
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "printf '\\e]9;Claude Code Task completed\\e\\\\' > /dev/tty"
}
]
}
]
}
}After saving the file, the configuration will take effect automatically. No need to restart Claude Code.
\e]9;...\e\\is ghostty terminal's desktop notification escape sequence- This sequence sends a desktop notification to ghostty displaying the specified message
- Clicking the notification will jump to the ghostty window
> /dev/ttyredirects output to the current terminal device
You can customize the notification by modifying the message content:
"command": "printf '\\e]9;Your custom message\\e\\\\' > /dev/tty"- The
Stophook triggers when Claude Code task execution is completed - Triggers regardless of whether the task succeeds or fails
-
Run a Claude Code task:
claude "Help me list files in the current directory" -
After the task completes, ghostty will display a desktop notification: "Claude Code Task completed"
Check settings.example.json for the complete configuration file example.
- This configuration only works with ghostty terminal
- Other terminals may use different notification mechanisms
- Ensure your ghostty version supports desktop notification functionality
This project uses the MIT License - see the LICENSE file for details.
