Skip to content

fix: set the window title that PS1 sets - #12

Merged
trancong12102 merged 1 commit into
masterfrom
fix/prompt-title
Nov 23, 2026
Merged

trancong12102 merged 1 commit into
masterfrom
fix/prompt-title

Conversation

@trancong12102

Copy link
Copy Markdown
Contributor

Problem

In Ghostty with bash + flyline, the tab title kept showing the last command after it finished. It never went back to the working directory.

Ghostty's bash integration sets the title by appending \[\e]2;\w\a\] to PS1 in its precmd. Debian's default .bashrc does the same with \[\e]0;\u@\h: \w\a\], and so does Kitty's integration. Readline prints those sequences along with the prompt. flyline draws the prompt itself, and ansi-to-tui drops OSC sequences, so the title was never set.

Fix

  • osc_title() in src/prompt_manager.rs finds the last OSC 0 or OSC 2 title in a decoded prompt. It accepts both BEL and ST terminators.
  • PromptStringBuilder::expand_prompt_string records that title, and PromptManager keeps the one PS1 sets.
  • App::run writes OSC 2 (control characters stripped) before drawing the prompt.
  • Guide: a Ghostty note on shell integration with flyline, including a suggested shell-integration-features line.
  • Changelog: added to the v2.0.3 entry. That version isn't tagged yet, so it ships together with fix: keep space-prefixed commands out of JSONL history (v2.0.3) #11.

Testing

  • cargo test --lib: 915 passed. New tests cover osc_title and the builder recording the title while keeping it out of the drawn prompt.
  • cargo fmt -- --check, clippy -D warnings and rustdoc -D warnings are clean.
  • Ran a pty bash session with Ghostty's ghostty.bash sourced and GHOSTTY_SHELL_FEATURES=cursor:blink,path,title, then captured the raw output. Each prompt now emits OSC 2;<cwd>. The 133 A/B/C/D marks and OSC 7 are unchanged.

🤖 Generated with Claude Code

Prompts often set the window title with an OSC 0 or OSC 2 sequence in
PS1: Debian's default .bashrc does, and Ghostty's and Kitty's shell
integration add the working directory as the title. Readline prints
these with the prompt. flyline draws the prompt itself and ansi-to-tui
drops OSC sequences, so the title was never set; in Ghostty the tab kept
showing the last command after it finished.

PromptStringBuilder now records the title from the decoded PS1, and the
app writes it out before drawing the prompt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trancong12102
trancong12102 merged commit a9572cf into master Nov 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant