claude-code
claude-code copied to clipboard
More configurable preferredNotifChannel (run an arbitrary script)
We should be able to have it run an arbitrary script/executable
claude config set --global preferredNotifChannel ~/.bin/notify.sh
That's a cool idea. What were you thinking of making your script do?
My most immediate use case would be something like this.
#!/usr/bin/env bash
/usr/bin/osascript -e 'display notification "Awaiting input" with title "Claude"'
If you passed in some info into the args, like if it's waiting for approval to do something or if it's completed a task (or if there was an error, ran out of context, etc) and maybe a (very short) summary of what it did, that could be put into the notification.
Honestly now that I think about it this could probably be an MCP server. But something simple like that would be sufficient.
Just to give a bit more context, iTerm2 is a bit dated. Things like Ghostty are more cutting edge and it happens to lack support for visual bell.
We don't yet have arbitrary scripts, but the new version does have better automatic notification behavior including support for Ghostty. Let us know if it works for you!
The bell doesn’t work in my terminal, making this a bottleneck. Just like other configs, we should be able to set a notification script: claude config set -g path_to_notification_script /path/to/notify.sh.
Claude should call it when needed, with args for type (e.g., permission request, completion) and brief text. I’d use it for custom sounds and notify-send.
What terminal are you using Roman? I hear you on the request for custom notification script - it makes sense, but we do want to have things work by default as broadly as possible as well.
What terminal are you using Roman?
I'm on a heavily customized setup, so defaults don’t apply
I'd love this feature too. Using terminator on arch.
I use ghostty with tmux. Tmux eats the OSC sequence (iterm2 style notifications). While I could setup the bell to do a proper notification, I do not want all bell trigger to do a notification. Just claude code.
Being able to setup a custom script would unblock anyone with a custom setup to self serve.
Supporting allow-passthrough for tmux would be nice too. https://github.com/tmux/tmux/wiki/FAQ#what-is-the-passthrough-escape-sequence-and-how-do-i-use-it
This would be such a win - I would also like notifications that are more elaborate (eg speak to me or ping my phone). Often I'm in another room (what a time to be alive! ;p) and want to know when my coding companion needs my help.
In MacOS there is this brew package https://github.com/julienXX/terminal-notifier that can send a MacOS native notification. It would be awesome if I can trigger this script with a custom message based on the state of Claude Code. For example, the notification can be different in the case of ClaudeCode waiting for user input or when it is done vibe-coding.
here is what i got working: create file
~/.claude/scripts/notify.sh
#!/bin/bash
osascript -e "display notification \"$2\" with title \"$1\" sound name \"Submarine\""
say "I'm done"
Patch cli.js make sure you back it up first this is for version 1.0.31
sed -i '' 's/hF5(A,B){return;/hF5(A,B){/g' /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js
This works for me, im investigating on how to get more notifications working e.g. when it ask a question with 3 answers you can choose from
UPDATE i got tired of looking at cli.js and asked claude to do this for me, seems to be working
# Add notification for KV function (general permissions)
sed -i '' '/z1("tengu_tool_use_show_permission_request",{messageID:A\.assistantMessage\.message\.id,toolName:A\.tool\.name})/a\
;(async()=>{try{if(ZA().customNotifyCommand)await hF5({title:"Claude Code",message:"Needs permission to proceed"},ZA().customNotifyCommand)}catch(e){}})()
' /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js
# Add notification for tH1 function (tool use permissions)
sed -i '' '/z1("tengu_tool_use_show_permission_request",{messageID:A\.assistantMessage\.message\.id,toolName:A\.tool\.name,isMcp:A\.tool\.isMcp/a\
;(async()=>{try{if(ZA().customNotifyCommand)await hF5({title:"Claude Code",message:"Needs permission to proceed"},ZA().customNotifyCommand)}catch(e){}})()
' /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js
This is already supported through Hooks now, so closing this issue now.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.