mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-03-20 17:06:49 +00:00
refactor(claude): migrate hooks to external scripts and add new hooks
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.
This commit is contained in:
30
.claude/hooks/post-edit-format.sh
Executable file
30
.claude/hooks/post-edit-format.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user