#!/bin/bash # Claude Code hook:把「忙/闲/等你」状态写回 tmux 的 pane_title(窗口列表里 claude: "..." 引号内那段) # 用法(settings.json hooks): # UserPromptSubmit / PreToolUse -> claude-tmux-busy-hook.sh busy (⏳) # Notification -> claude-tmux-busy-hook.sh wait (❗) # Stop -> claude-tmux-busy-hook.sh idle (✳) # 只在 tmux 里生效;不在 tmux 里静默退出。Linux/macOS 通用(不依赖 sed 的多字节支持)。 [ -n "$TMUX_PANE" ] || exit 0 tty=$(tmux display -p -t "$TMUX_PANE" '#{pane_tty}' 2>/dev/null) || exit 0 cur=$(tmux display -p -t "$TMUX_PANE" '#{pane_title}' 2>/dev/null) base=$cur for g in '✳' '⏳' '❗' '✅'; do base=${base#"$g"}; done base=${base# } case "$1" in busy) g='⏳' ;; wait) g='❗' ;; *) g='✳' ;; esac printf '\033]0;%s %s\007' "$g" "$base" > "$tty" exit 0