Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created August 31, 2026 23:21
Show Gist options
  • Select an option

  • Save pamelafox/c9cb3e000fdf127741b121d7c5abbf02 to your computer and use it in GitHub Desktop.

Select an option

Save pamelafox/c9cb3e000fdf127741b121d7c5abbf02 to your computer and use it in GitHub Desktop.
VS Code agent completion sound and spoken thread title hook
{
"hooks": {
"Stop": [
{
"type": "command",
"command": "/bin/zsh ~/.copilot/hooks/agent-complete-sound.sh",
"timeout": 30
}
]
}
}
#!/bin/zsh
set -u
hook_input=$(cat)
session_id=$(print -r -- "$hook_input" | /usr/bin/jq -r '.session_id // empty')
transcript_path=$(print -r -- "$hook_input" | /usr/bin/jq -r '.transcript_path // empty')
/usr/bin/afplay "$HOME/Documents/sierra_trimmed2.m4a" || true
idle_nanoseconds=$(/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/awk '/HIDIdleTime/ { print $NF; exit }')
if [[ ! "$idle_nanoseconds" =~ '^[0-9]+$' ]] || (( idle_nanoseconds < 60000000000 )); then
exit 0
fi
title=""
if [[ -n "$session_id" && -n "$transcript_path" ]]; then
workspace_storage_dir="${transcript_path%/GitHub.copilot-chat/transcripts/*}"
session_file="$workspace_storage_dir/chatSessions/$session_id.jsonl"
if [[ -f "$session_file" ]]; then
title=$(/usr/bin/jq -rs 'map(select(.kind == 1 and .k == ["customTitle"])) | last | .v // empty' "$session_file" 2>/dev/null)
fi
fi
if [[ -n "$title" ]]; then
/usr/bin/say "$title"
else
/usr/bin/say "Agent finished"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment