Files
claude-hud/scripts/cleanup.sh
Jarrod Watts 36b2a09210 docs: add project documentation and improve robustness
- Add ARCHITECTURE.md, FAQ.md, LLM.md documentation
- Add LICENSE (MIT), CODE_OF_CONDUCT.md, PR template
- Add .editorconfig for consistent formatting
- Add check.sh script for validation
- Fix ESLint errors in hud-config.ts and settings-reader.ts
- Various test and component improvements

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:17:50 +11:00

41 lines
1022 B
Bash
Executable File

#!/bin/bash
set -uo pipefail
command -v jq &>/dev/null || exit 0
INPUT=$(cat)
if ! echo "$INPUT" | jq empty 2>/dev/null; then
exit 0
fi
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty')
if [[ -z "$SESSION_ID" || ! "$SESSION_ID" =~ ^[a-zA-Z0-9_-]+$ ]]; then
exit 0
fi
HUD_DIR="$HOME/.claude/hud"
EVENT_FIFO="$HUD_DIR/events/$SESSION_ID.fifo"
PID_FILE="$HUD_DIR/pids/$SESSION_ID.pid"
REFRESH_FILE="$HUD_DIR/refresh.json"
# Only close the HUD if this session is still the active one.
# This keeps HUD alive for /new while closing on /exit or terminal close.
if [ -f "$REFRESH_FILE" ]; then
CURRENT_SESSION=$(jq -r '.sessionId // empty' "$REFRESH_FILE" 2>/dev/null)
if [ "$CURRENT_SESSION" = "$SESSION_ID" ]; then
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE" 2>/dev/null)
if [ -n "$PID" ] && kill -0 "$PID" 2>/dev/null; then
kill "$PID" 2>/dev/null || true
fi
fi
fi
fi
# Clean up FIFO and pid file for this session
rm -f "$EVENT_FIFO"
rm -f "$PID_FILE"
exit 0