Repository navigation
fix: set the window title that PS1 sets - #12
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.bashrcdoes 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, andansi-to-tuidrops OSC sequences, so the title was never set.Fix
osc_title()insrc/prompt_manager.rsfinds the last OSC 0 or OSC 2 title in a decoded prompt. It accepts both BEL and ST terminators.PromptStringBuilder::expand_prompt_stringrecords that title, andPromptManagerkeeps the one PS1 sets.App::runwritesOSC 2(control characters stripped) before drawing the prompt.shell-integration-featuresline.Testing
cargo test --lib: 915 passed. New tests coverosc_titleand the builder recording the title while keeping it out of the drawn prompt.cargo fmt -- --check, clippy-D warningsand rustdoc-D warningsare clean.ghostty.bashsourced andGHOSTTY_SHELL_FEATURES=cursor:blink,path,title, then captured the raw output. Each prompt now emitsOSC 2;<cwd>. The 133 A/B/C/D marks and OSC 7 are unchanged.🤖 Generated with Claude Code