Claude Code Hooks
Set up notifications for Claude Code using cmuxterm hooks
Claude Code Hooks
cmuxterm integrates with Claude Code via hooks to notify you when tasks complete or when Claude needs attention.
Detecting cmuxterm
Before sending notifications, you should detect if you're running inside cmuxterm to avoid conflicts with other terminals.
Detection Methods
1. Check for the socket:
2. Check for the CLI:
3. Check the TERM_PROGRAM environment variable:
cmuxterm sets TERM_PROGRAM=ghostty since it's built on Ghostty. Use the socket check to distinguish from regular Ghostty.
Setting Up Hooks
Claude Code supports hooks that run on specific events. Add these to your ~/.claude/settings.json:
Notification Hook Script
Create a script that checks for cmuxterm and sends notifications:
Make it executable:
Example Configurations
Notify on All Completions
Get notified whenever Claude Code finishes a task:
Notify on Long-Running Tasks
Only notify for Task tool completions (agent subprocesses):
Notify on Errors
Add error notifications:
Advanced: Conditional Notifications
Only notify if the terminal is not focused:
Using OSC Sequences Directly
If you prefer not to use the CLI, you can emit OSC sequences directly:
Full Example Setup
- Create the hooks directory:
- Create the notification script:
- Configure Claude Code:
- Restart Claude Code to apply the hooks.
Now you'll receive desktop notifications in cmuxterm whenever Claude Code finishes a task or needs attention.