Skip to content

prompt: default prompt colors to the terminal foreground#1046

Open
iniw wants to merge 1 commit intonushell:mainfrom
iniw:reset-prompt
Open

prompt: default prompt colors to the terminal foreground#1046
iniw wants to merge 1 commit intonushell:mainfrom
iniw:reset-prompt

Conversation

@iniw
Copy link
Copy Markdown

@iniw iniw commented Apr 8, 2026

#992 reset stale sgr state before each repaint, which fixed prompt color bleed from previous command output. it did not fix the starship case reported in starship/starship#6560 and nushell/nushell#16384 because reedline still applied its own default prompt colors immediately before printing the prompt.

that meant a prompt implementation that returned ansi text without overriding get_prompt_color() still inherited reedline's defaults. for starship, style = "none" emits no color sequence at all, so the first visible character inherited reedline's green prompt color instead of the terminal's foreground color.

this patch changes the default prompt, multiline, indicator, and right-prompt colors to the terminal defaults. prompts that want explicit colors can still override the color methods, but unstyled prompts now stay unstyled and no longer need an extra reset sequence to avoid the green first character.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 8, 2026

We've covered this in the past. If we set these to none then there are no colors for the prompt at all for reedline users unless you're using something else to color your prompt.

@iniw
Copy link
Copy Markdown
Author

iniw commented Apr 8, 2026

i don't think you're right (but i'm not fully sure either!). AFAIK emitting text without a color (which is the case in this patch) will just default to the terminal's foreground color, right? so the actual color of the prompt will depend on the user's terminal emulator

what i mean is that there will be colors, it just won't be controlled by reedline

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 8, 2026

This is what I'm talking about. I really don't want to lose the default coloring in reedline.

Before this PR

image

After this PR

image

@iniw
Copy link
Copy Markdown
Author

iniw commented Apr 8, 2026

i understand where you're coming from but i see it the other way around:

users of reedline (including the examples) should override the get_*_color family of functions in the Prompt trait to achieve their desired styling.
reedline, by default, shouldn't impose a particular style on the prompt. it's too low-level for that.

this is just my personal opinion, of course :)

do you think me making the examples colorful again (by overriding the colors) but keeping the default color-less would be a good middle ground?

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 8, 2026

do you think me making the examples colorful again (by overriding the colors) but keeping the default color-less would be a good middle ground?

maybe. i also wonder if we'd need to do this too in nushell when running nu -n

pr nushell#992 reset stale sgr state before each repaint, which fixed prompt
color bleed from previous command output. it did not fix the starship
case reported in starship#6560 and nushell#16384 because reedline still
applied its own default prompt colors immediately before printing the
prompt.

that meant a prompt implementation that returned ansi text without
overriding `get_prompt_color()` still inherited reedline's defaults.
for starship, `style = "none"` emits no color sequence at all, so the
first visible character inherited reedline's green prompt color instead
of the terminal's foreground color.

this patch changes the default prompt, multiline, indicator, and right-prompt
colors to the terminal defaults. prompts that want explicit colors can
still override the color methods, but unstyled prompts now stay
unstyled and no longer need an extra reset sequence to avoid the green
first character.
@iniw
Copy link
Copy Markdown
Author

iniw commented Apr 9, 2026

okay, I've made the DefaultPrompt impl use the old styles. lmk if this is more acceptable now

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 17, 2026

I think it's good. Can you look into what changes are needed in nushell to support this?

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.

2 participants