Skip to content

More configurable preferredNotifChannel (run an arbitrary script) #104

Closed

Description

@tylerkahn

We should be able to have it run an arbitrary script/executable

claude config set --global preferredNotifChannel ~/.bin/notify.sh

Activity

  1. bcherny commented on Feb 26, 2025

    @bcherny
    Collaborator

    That's a cool idea. What were you thinking of making your script do?

  2. tylerkahn commented on Feb 26, 2025

    @tylerkahn
    Author

    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.

  3. tylerkahn commented on Feb 26, 2025

    @tylerkahn
    Author

    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.

  4. igorkofman commented on Mar 12, 2025

    @igorkofman
    Collaborator

    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!

  5. Roman- commented on Mar 15, 2025

    @Roman-

    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.

  6. igorkofman commented on Mar 16, 2025

    @igorkofman
    Collaborator

    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.

  7. Roman- commented on Mar 17, 2025

    @Roman-

    What terminal are you using Roman?

    I'm on a heavily customized setup, so defaults don’t apply

  8. hirowatari commented on May 16, 2025

    @hirowatari

    I'd love this feature too. Using terminator on arch.

  9. JoeDupuis commented on May 26, 2025

    @JoeDupuis

    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

  10. jkp commented on Jun 7, 2025

    @jkp

    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.

  11. AnhQuanTrl commented on Jun 19, 2025

    @AnhQuanTrl

    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.

  12. n0x00x commented on Jun 21, 2025

    @n0x00x

    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
  13. kushal-thakkar commented on Aug 22, 2025

    @kushal-thakkar

    This is already supported through Hooks now, so closing this issue now.

  14. github-actions commented on Aug 31, 2025

    @github-actions

    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.

  15. locked as resolved and limited conversation to collaborators on Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions