Files
asepharyana-hub-guide/hooks/scripts/detect-file-type.sh
T
asepharyana 95a91d7bf5 fix(hooks): restore with proper SessionStart matchers
- Add matcher: startup|resume|compact for SessionStart (per docs)
- PreToolUse reads from stdin per documented hook input format
- Remove  arg, use stdin-based approach
- Scripts read event JSON from stdin as documented
- Plain text output, no special characters
2026-07-26 12:03:49 +07:00

19 lines
870 B
Bash
Executable File

#!/bin/bash
# hub-guide: detect file extension and suggest language-specific rules
# Reads PreToolUse event JSON from stdin.
set -euo pipefail
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | grep -o '"file_path"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"file_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
EXT="${FILE_PATH##*.}"
case "$EXT" in
ts|tsx) echo "[hub-guide] .${EXT} -> typescript" ;;
py) echo "[hub-guide] .py -> python" ;;
rs) echo "[hub-guide] .rs -> rust" ;;
go) echo "[hub-guide] .go -> go" ;;
js|jsx) echo "[hub-guide] .${EXT} -> typescript" ;;
Dockerfile|dockerfile) echo "[hub-guide] Dockerfile -> docker" ;;
yml|yaml) echo "[hub-guide] .${EXT} -> ci-cd+docker" ;;
esac