[BUG] Terminal title is blanked on exit instead of restored, corrupting tmux-resurrect saves

Status Open
Reported on v2.1.227
Maintainer reply None cached
Activity 1 comment · opened Aug 11, 2026

What's Wrong?

On exit, Claude Code writes an empty OSC 2 terminal title instead of restoring the title that was there before it started. It never saves the prior title, so whatever the user or a previous program had set is destroyed rather than restored.

Under tmux this is more than cosmetic. #{pane_title} is sticky — it defaults to the hostname and nothing ever reverts it — so the pane keeps an empty title indefinitely after Claude Code exits.

That silently corrupts tmux-resurrect saves. Its save.sh parses pane records with IFS=$'\t' read, and tab is IFS whitespace in bash, so an empty field collapses and every field after it shifts left one position. pane_current_path lands in the wrong slot, and on restore the pane falls back to $HOME. The result is that panes silently lose their working directories across a save/restore cycle — only the panes where Claude Code had been run and exited.

What Should Happen?

Use the xterm title stack: push on startup (CSI 22;2t) and pop on exit (CSI 23;2t). Other TUI programs do this — nvim and lazygit both leave a pre-existing title intact across a full run.

Failing that, emit no title write at all on exit. Leaving a stale title is strictly better than destroying the user's.

Error Messages/Logs

# Control: no CLAUDE_CODE_DISABLE_TERMINAL_TITLE
marker set:       [MARKER]
claude running:   [✳ Claude Code]
after /exit:      []              # blanked, not restored

# Same steps with CLAUDE_CODE_DISABLE_TERMINAL_TITLE=1
marker set:       [MARKER]
claude running:   [MARKER]        # never touched
after /exit:      [MARKER]

Steps to Reproduce

  1. Start a tmux session and make sure the shell is not setting the title itself (with oh-my-zsh: DISABLE_AUTO_TITLE=true).
  2. Set a known pane title:

``sh
printf '\033]2;MARKER\007'
``

  1. Confirm it took: tmux display -p -F '#{pane_title}'MARKER
  2. Run claude, then /exit.
  3. Check again: tmux display -p -F '#{pane_title}'empty. Expected MARKER.

To see the downstream effect with tmux-resurrect installed: run the save script and inspect the saved file. Pane records whose title is empty have 11 tab-separated fields with pane_current_path shifted out of field 8, e.g.

pane<TAB>sess<TAB>1<TAB>0<TAB>:-<TAB>0<TAB>:/some/path<TAB>1<TAB>zsh<TAB>4462<TAB>:

versus a well-formed record, where the title occupies field 7 and the path field 8:

pane<TAB>sess<TAB>1<TAB>0<TAB>:-<TAB>0<TAB>sometitle<TAB>:/some/path<TAB>1<TAB>zsh<TAB>:

Restoring from the first form puts the pane in $HOME.

Claude Model

Opus

Is this a regression?

I don't know

Claude Code Version

2.1.227 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other — Ghostty (outer) + tmux 3.5a, zsh

Additional Information

CLAUDE_CODE_DISABLE_TERMINAL_TITLE=1 avoids the problem entirely, and works from the env block of settings.json as well as the shell environment. But it's a workaround with costs: it disables the useful session-topic title too, it is undocumented (absent from the settings env table), and per #84789 it is ignored for background sessions.

Existing related issues are all requests to disable the title — #21677 (closed, not planned), #31107 (closed as duplicate), #76092, #17951. This report is different: the title feature is fine, the defect is that exit clobbers the previous title instead of restoring it.

The tab-collapsing behaviour in tmux-resurrect is arguably a bug on their side too, but Claude Code blanking the title is what triggers it, and the fix here (save/restore rather than blank) is well-defined regardless.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗