Last active
September 15, 2025 17:06
-
-
Save ericboehs/68182f6a3642f0fe899299a08383f99d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# claude-notify - Notification handler for Claude Code hooks | |
# Parse command line arguments | |
sender="" | |
while [[ $# -gt 0 ]]; do | |
case $1 in | |
--sender) | |
sender="$2" | |
shift 2 | |
;; | |
*) | |
echo "Unknown option: $1" | |
exit 1 | |
;; | |
esac | |
done | |
# Read JSON from stdin | |
json=$(cat) | |
# Get tmux info if available | |
if [[ -n "$TMUX" ]]; then | |
tmux_info=$(tmux display-message -p '#T (#S:#{window_index}.#{pane_index})') | |
else | |
tmux_info="Session" | |
fi | |
# Build terminal-notifier command with optional sender | |
build_notifier_cmd() { | |
local title="$1" | |
local message="$2" | |
local cmd="terminal-notifier -title \"$title\" -message \"$message\"" | |
if [[ -n "$sender" ]]; then | |
cmd="$cmd -sender \"$sender\"" | |
fi | |
echo "$cmd" | |
} | |
# Check if this is a notification with title/message or a stop hook | |
if echo "$json" | jq -e '.title and .message' >/dev/null 2>&1; then | |
# Notification payload | |
title=$(echo "$json" | jq -r '.title') | |
message=$(echo "$json" | jq -r '.message') | |
cmd=$(build_notifier_cmd "$title" "$tmux_info: $message") | |
eval "$cmd" | |
else | |
# Stop hook payload | |
cmd=$(build_notifier_cmd "Claude Code Stopped" "$tmux_info is ready for further instruction.") | |
eval "$cmd" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
claude-notify
A notification handler for Claude Code hooks that sends macOS notifications via terminal-notifier.
Features
Usage
This script is designed to be used as a Claude Code hook. It reads JSON from stdin and sends appropriate notifications.
Command Line Options
--sender <app>
: Specify the sender application for notifications (optional)Hook Integration
Add to your Claude Code hooks configuration to receive notifications when operations complete.
Requirements
brew install terminal-notifier
)brew install jq
)How it works