Skip to content

Commit 9e45acf

Browse files
committed
Sync tmux window name to Claude Code's task summary title
Claude Code writes an auto-generated summary of the current task to the terminal title, but tmux windows showed only the version number. A SessionStart hook sets window-local automatic-rename options so the window name tracks the pane title live (truncated to 22 cells, ~10 CJK characters), updating in real time as the task summary and busy/idle spinner change. A SessionEnd hook unsets the window-local options to restore normal tmux naming.
1 parent 1677505 commit 9e45acf

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
# Claude Code SessionStart hook: while Claude Code runs inside tmux, keep the
3+
# window name synced to Claude Code's terminal title — an auto-generated
4+
# summary of the current task that updates as the conversation evolves —
5+
# instead of the version-number default. Implemented with window-local tmux
6+
# options so tmux tracks the title live with no further hook invocations.
7+
# The SessionEnd hook in settings.json unsets them to restore normal naming.
8+
9+
[ -n "$TMUX" ] && [ -n "$TMUX_PANE" ] || exit 0
10+
11+
# #{=22:...} truncates by cell width: 22 cells is roughly 10 CJK characters.
12+
tmux set-option -w -t "$TMUX_PANE" automatic-rename-format '#{=22:pane_title}' 2>/dev/null
13+
tmux set-option -w -t "$TMUX_PANE" automatic-rename on 2>/dev/null
14+
exit 0

rc.d/claude/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@
4848
]
4949
}
5050
],
51+
"SessionStart": [
52+
{
53+
"hooks": [
54+
{
55+
"type": "command",
56+
"command": "$HOME/dotfiles/rc.d/claude/hooks/tmux-window-title.sh"
57+
}
58+
]
59+
}
60+
],
61+
"SessionEnd": [
62+
{
63+
"hooks": [
64+
{
65+
"type": "command",
66+
"command": "[ -n \"$TMUX\" ] && [ -n \"$TMUX_PANE\" ] && { tmux set-option -w -t \"$TMUX_PANE\" -u automatic-rename-format; tmux set-option -w -t \"$TMUX_PANE\" -u automatic-rename; } 2>/dev/null || true"
67+
}
68+
]
69+
}
70+
],
5171
"Stop": [
5272
{
5373
"hooks": [

0 commit comments

Comments
 (0)