Last active
January 9, 2026 07:43
-
-
Save n0mimono/b4f6c370d057cd0fa57eef3fbab0bbe4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| input=$(cat) | |
| EVENT=$(echo "$input" | jq -r '.hook_event_name') | |
| NOTIF_TYPE=$(echo "$input" | jq -r '.notification_type // empty') | |
| case "$EVENT" in | |
| "Stop") | |
| terminal-notifier -title "Claude Code" -message "処理が完了しました" -sound "Glass" | |
| ;; | |
| "Notification") | |
| case "$NOTIF_TYPE" in | |
| "permission_prompt") | |
| terminal-notifier -title "Claude Code" -message "承認が必要です" -sound "Ping" | |
| ;; | |
| "idle_prompt") | |
| terminal-notifier -title "Claude Code" -message "入力を待っています" -sound "Purr" | |
| ;; | |
| *) | |
| terminal-notifier -title "Claude Code" -message "通知があります" -sound default | |
| ;; | |
| esac | |
| ;; | |
| esac | |
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "model": "opus", | |
| "permissions": { | |
| "allow": [ | |
| "Bash(ls:*)", | |
| "Bash(pwd:*)", | |
| "Bash(cat:*)", | |
| "Bash(head:*)", | |
| "Bash(tail:*)", | |
| "Bash(echo:*)", | |
| "Bash(which:*)", | |
| "Bash(whoami:*)", | |
| "Bash(date:*)", | |
| "Bash(env:*)", | |
| "Bash(printenv:*)", | |
| "Bash(wc:*)", | |
| "Bash(file:*)", | |
| "Bash(tree:*)", | |
| "Bash(git status:*)", | |
| "Bash(git log:*)", | |
| "Bash(git diff:*)", | |
| "Bash(git branch:*)", | |
| "Bash(git show:*)", | |
| "Bash(npm list:*)", | |
| "Bash(npm outdated:*)", | |
| "Bash(node --version:*)", | |
| "Bash(python --version:*)", | |
| "Bash(cargo --version:*)", | |
| "Bash(docker ps:*)", | |
| "Bash(docker images:*)", | |
| "Bash(docker volume ls:*)", | |
| "Bash(docker network ls:*)", | |
| "Bash(docker logs:*)", | |
| "Bash(docker inspect:*)", | |
| "Bash(docker-compose ps:*)", | |
| "Bash(docker-compose logs:*)" | |
| ] | |
| }, | |
| "statusLine": { | |
| "type": "command", | |
| "command": "~/.claude/statusline.sh" | |
| }, | |
| "hooks": { | |
| "Stop": [ | |
| { | |
| "hooks": [ | |
| { | |
| "type": "command", | |
| "command": "~/.claude/notify.sh" | |
| } | |
| ] | |
| } | |
| ], | |
| "Notification": [ | |
| { | |
| "matcher": "", | |
| "hooks": [ | |
| { | |
| "type": "command", | |
| "command": "~/.claude/notify.sh" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| input=$(cat) | |
| # データ抽出 | |
| MODEL=$(echo "$input" | jq -r '.model.display_name') | |
| CONTEXT_SIZE=$(echo "$input" | jq -r '.context_window.context_window_size') | |
| USAGE=$(echo "$input" | jq '.context_window.current_usage') | |
| COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0') | |
| DURATION_MS=$(echo "$input" | jq -r '.cost.total_duration_ms // 0') | |
| LINES_ADDED=$(echo "$input" | jq -r '.cost.total_lines_added // 0') | |
| LINES_REMOVED=$(echo "$input" | jq -r '.cost.total_lines_removed // 0') | |
| # ANSI色定義 | |
| GREEN='\033[32m' | |
| YELLOW='\033[33m' | |
| RED='\033[31m' | |
| RESET='\033[0m' | |
| # コンテキスト使用率計算 | |
| if [ "$USAGE" != "null" ]; then | |
| CURRENT_TOKENS=$(echo "$USAGE" | jq '.input_tokens + .cache_creation_input_tokens + .cache_read_input_tokens') | |
| PERCENT=$((CURRENT_TOKENS * 100 / CONTEXT_SIZE)) | |
| else | |
| PERCENT=0 | |
| fi | |
| # プログレスバー生成(10文字) | |
| FILLED=$((PERCENT / 10)) | |
| EMPTY=$((10 - FILLED)) | |
| BAR="" | |
| for ((i=0; i<FILLED; i++)); do BAR+="■"; done | |
| for ((i=0; i<EMPTY; i++)); do BAR+="░"; done | |
| # 使用率の色決定 | |
| if [ $PERCENT -le 60 ]; then | |
| CONTEXT_COLOR=$GREEN | |
| elif [ $PERCENT -le 80 ]; then | |
| CONTEXT_COLOR=$YELLOW | |
| else | |
| CONTEXT_COLOR=$RED | |
| fi | |
| # 経過時間をフォーマット(分:秒) | |
| DURATION_SEC=$((DURATION_MS / 1000)) | |
| MINUTES=$((DURATION_SEC / 60)) | |
| SECONDS=$((DURATION_SEC % 60)) | |
| TIME_STR=$(printf "%d:%02d" $MINUTES $SECONDS) | |
| # コストフォーマット | |
| COST_STR=$(printf "\$%.2f" "$COST") | |
| # Gitブランチ取得 | |
| GIT_BRANCH="" | |
| if git rev-parse --git-dir > /dev/null 2>&1; then | |
| GIT_BRANCH=$(git branch --show-current 2>/dev/null) | |
| fi | |
| # 出力組み立て | |
| OUTPUT="[$MODEL] ${CONTEXT_COLOR}${BAR} ${PERCENT}%${RESET}" | |
| OUTPUT+=" | ${COST_STR}" | |
| OUTPUT+=" | ${TIME_STR}" | |
| OUTPUT+=" | ${GREEN}+${LINES_ADDED}${RESET}/${RED}-${LINES_REMOVED}${RESET}" | |
| if [ -n "$GIT_BRANCH" ]; then | |
| OUTPUT+=" | ${GIT_BRANCH}" | |
| fi | |
| echo -e "$OUTPUT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment