fix(themes/powerline): ensure prompt starts on a new line#2385
Open
seefood wants to merge 5 commits into
Open
Conversation
When a command's output has no trailing newline, \e[G (column 1) in PS1 would overwrite that output with the prompt. Add a missing-newline indicator in PROMPT_COMMAND: reversed-video % marks the incomplete line, then \r\e[K moves to column 1 and clears it, so the prompt always renders cleanly regardless of the previous command's output. Fixes Bash-it#2372 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Verifies that __powerline_prompt_command: - outputs the \e[7m%\e[0m\r\e[K sequence to stdout - outputs it as the very first bytes (before segment/PS1 content) Uses a no-op stub segment and a _save-and-reload-history stub to avoid pulling in every plugin that the default segments depend on. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the reversed-% + \e[K approach (which cleared the previous command's unterminated output instead of preserving it) with the fix suggested by @joshiste in Bash-it#2372: pad the current line with COLUMNS-1 spaces so the terminal auto-wraps the cursor to a fresh line, then carriage-return to column 1. This preserves any partial output from the previous command instead of erasing it. The \e[G reset in PS1 is now redundant since the cursor is already at column 1 by the time PS1 is rendered, so beginning_of_line is removed. Fixes Bash-it#2372
Contributor
Author
|
Updated the implementation based on the feedback in #2372: the reversed- Replaced it with the approach Tests updated accordingly ( |
…missing-newline * origin/master: Fix get_default_branch function fix(themes/powerline): remove erroneous \e[G from PS1 test(themes/powerline): suppress SC2034 for externally-consumed variables test(themes/powerline): add BATS tests for POWERLINE_PROMPT_FOREGROUND_COLOR fix(themes/powerline): restore POWERLINE_PROMPT_FOREGROUND_COLOR support # Conflicts: # test/themes/powerline.base.bats
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.
Summary
When a command produces output without a trailing newline (e.g.
echo -n foo), the existing\e[G(move to column 1) inPS1overwrites that output with the prompt. This adds a missing-newline handler at the top of__powerline_prompt_command:How it works:
\e[7m%\e[0m— prints a reversed-video%at the current cursor position. If the previous command left the cursor mid-line, this character is briefly visible as a "missing newline" indicator (same convention as zsh'sPROMPT_SP)\r— carriage return to column 1 of the current line\e[K— clear from column 1 to end of lineResult:
%is printed and immediately cleared → no visible change%appears at the end of the partial output, then\r\e[Kclears the entire line → prompt renders cleanly on what is now an empty lineThe existing
\e[GinPS1is kept as-is (it becomes a harmless no-op since we are already at column 1 after theprintf).Note:
powerline-multilineuses\e[B(cursor down) instead of\e[Gand has different behaviour; that theme is out of scope for this fix.Test plan
echo -n foo— verify%appears briefly then prompt renders on a clean new line,foois not overwrittenecho foo,ls) — verify no extra blank line is insertedpowerline,powerline-plain, andpowerline-naked(plain and naked inherit__powerline_prompt_commandfrom base)Fixes #2372
🤖 Generated with Claude Code