Skip to content

OSC 0/2 escape sequences do not update pane_title #231

@psmux

Description

@psmux

Summary

OSC 0 and OSC 2 escape sequences (used by applications to set the terminal/pane title) do not propagate to pane_title (#{pane_title} / #T format variable).

In tmux, when a child process sends an OSC 0 or OSC 2 sequence, the pane title is updated immediately (gated by the allow-set-title option). In psmux, the vt100 parser correctly stores the title from OSC sequences, but the propagation from the parser to pane.title only happens inside the DumpState handler, which only runs when a TUI client is attached. For detached sessions or CLI queries, the pane title never reflects OSC updates.

Environment

Windows (ConPTY / PowerShell 7 as default shell)

Steps to reproduce

psmux new-session -d -s osc_test
psmux send-keys -t osc_test "Write-Host -NoNewline ([char]27 + ']2;MY_CUSTOM_TITLE' + [char]7)" Enter
Start-Sleep 3
psmux display-message -t osc_test -p '#{pane_title}'

Observed behavior

pane_title stays as the hostname (e.g. SUPERTOP) and never updates to MY_CUSTOM_TITLE.

Expected behavior

pane_title should reflect the latest OSC 0/2 title set by the child process (matching tmux behavior), as long as allow-set-title is on.

Root cause

The OSC title propagation code in server/mod.rs was:

  1. Only called inside the DumpState handler (never runs for detached sessions)
  2. Nested inside the (auto_rename || allow_rename) guard, making it dependent on window rename settings
  3. Not called before state query commands like display-message, list-panes, list-windows

tmux reference

In tmux input.c, input_exit_osc() for OSC 0 and 2:

if (wp != NULL &&
    options_get_number(wp->options, "allow-set-title") &&
    screen_set_title(sctx->s, p)) {
    notify_pane("pane-title-changed", wp);
}

The title is stored directly in wp->base.title and immediately available via #{pane_title}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions