mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-03-20 13:06:45 +00:00
Replace inline command strings in settings.json with external scripts in .claude/hooks/ for readability and maintainability. Consolidate three PostToolUse formatters into one script and add markdown/yaml formatting. Add new hooks: SessionStart context banner, Stop lint gate, async Bats test runner, idle desktop notification, and PostToolUseFailure logger.
31 lines
833 B
Bash
Executable File
31 lines
833 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Post-edit formatter: auto-format file based on extension.
|
|
# Receives tool output JSON on stdin.
|
|
|
|
fp=$(jq -r '.tool_input.file_path // empty')
|
|
[ -z "$fp" ] || [ ! -f "$fp" ] && exit 0
|
|
|
|
case "$fp" in
|
|
*.sh | */bin/*)
|
|
head -1 "$fp" | grep -qE '^#!.*(ba)?sh' \
|
|
&& command -v shfmt > /dev/null \
|
|
&& shfmt -i 2 -bn -ci -sr -fn -w "$fp"
|
|
;;
|
|
*.fish)
|
|
command -v fish_indent > /dev/null && fish_indent -w "$fp"
|
|
;;
|
|
*.lua)
|
|
command -v stylua > /dev/null && stylua "$fp"
|
|
;;
|
|
*.md)
|
|
command -v biome > /dev/null && biome format --write "$fp" 2> /dev/null
|
|
command -v markdown-table-formatter > /dev/null \
|
|
&& markdown-table-formatter "$fp" 2> /dev/null
|
|
;;
|
|
*.yml | *.yaml)
|
|
command -v prettier > /dev/null && prettier --write "$fp" 2> /dev/null
|
|
;;
|
|
esac
|
|
|
|
exit 0
|