Dynamic Tmux Window Naming with Claude Code
说明与用途
自动将 tmux 窗口重命名为当前 Claude Code 任务,提升终端中的上下文意识。
问题
Automatically rename tmux windows to reflect current Claude Code task without manual intervention.
结果
Tmux status bar now displays concise, task‑specific window names such as "claude-fix-auth" or "claude-code", improving context awareness across sessions.
工作流
- Create ~/.claude/instructions.md with window‑management rules
- Create ~/.claude/approve-tmux.py to auto‑approve tmux rename-window commands
- Make the script executable
- Add a PreToolUse hook in ~/.claude/settings.json that runs the approval script
- Start Claude Code; it reads instructions and monitors task changes
- When a significant topic change is detected, Claude Code runs tmux rename-window
- The hook auto‑approves the command, renaming the window silently
证据
First, I created a custom instructions file that Claude Code reads on startup
Create ~/.claude/approve-tmux.py
Add a PreToolUse hook in ~/.claude/settings.json that runs the approval script
- 记录日期: 2026-10-26T11:26:23.549Z