Skip to content

refactor(prompt)!: use nu_ansi_term::Color throughout Prompt Trait#1128

Merged
kronberger-droid merged 3 commits into
nushell:mainfrom
kronberger-droid:change-crossterm-color-to-nu-ansi
Jul 22, 2026
Merged

refactor(prompt)!: use nu_ansi_term::Color throughout Prompt Trait#1128
kronberger-droid merged 3 commits into
nushell:mainfrom
kronberger-droid:change-crossterm-color-to-nu-ansi

Conversation

@kronberger-droid

@kronberger-droid kronberger-droid commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Three functions of the Prompt Trait returned crossterm::Color instead of the established nu_ansi_term::Color.
This PR changes this to match the convention of the repo.

In turn I had to change the const DEFAULT_PROMPT_*_COLOR values to match the default palette.
These will now also be exported such that nushell does not have to define it itself in nushell/nushell#18686.
Also I switched the crossterm::Color reexport to nu_ansi_term::Color.

This change should be Behavior Preserving, but introduces a...

Breaking Change!:

The four Prompt Trait functions get_*_color(&self) now all return nu_ansi_term::Color instead of crossterm::Color.
This will force every downstream consumer to change its Trait Implementation!

Additional notes

added tests to pin prompt color output across the switch
related #1046, nushell/nushell#18686

@kronberger-droid

kronberger-droid commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Since nushell/nushell#18686 is not merged now we can just update the reedline reference and don't have to change anything else, since nushell used the default impls from reedline before.
I will then adapt the PR to reflect the changes introduced here.

@fdncred

fdncred commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

ok, we can land this when you're ready.

BREAKING CHANGE: Prompt::get_prompt_color, get_indicator_color and
get_prompt_right_color now take nu_ansi_term::Color, and reedline::Color
re-exports it instead of crossterm's. Note crossterm's Green/Cyan are the
bright palette entries; the nu-ansi-term equivalents are LightGreen/LightCyan.
crossterm's Green/Cyan are palette 10/14 (it spells the dark ones
DarkGreen/DarkCyan); nu-ansi-term's are 2/6. The name-for-name
translation darkened the prompt and indicator. Use LightGreen/LightCyan,
which also match nushell's light_green / light_cyan config names.
Covers the SGR bytes emitted for prompt, indicator and right prompt on
both buffer paths: the trait defaults, Color::Default emitting an
explicit SGR 39 (nushell#1046), the use_ansi_coloring guards, and that
crossterm's Green/Cyan were the bright palette entries.
@kronberger-droid
kronberger-droid force-pushed the change-crossterm-color-to-nu-ansi branch from e1942c0 to cf4652e Compare July 22, 2026 13:37
@kronberger-droid
kronberger-droid merged commit 9e27ab7 into nushell:main Jul 22, 2026
7 checks passed
fdncred pushed a commit to nushell/nushell that referenced this pull request Jul 22, 2026
<!--
Thanks for contributing to Nushell!

Before submitting, please read the contributing guide:
https://github.com/nushell/nushell/blob/main/CONTRIBUTING.md

This template helps reviewers understand your changes and allows us to
generate high-quality release notes.
-->

## Description
<!--
Explain what this PR does and why.

This section is intentionally flexible:
- Describe the problem
- Explain your approach
- Include technical details if relevant

Good examples:
- "In this PR, I fixed..."
- "In this PR, I added support for..."
- "This change improves X by..."

Write as much or as little as needed for reviewers to understand your
changes.
-->

Includes nushell/reedline#1128, which switches
the `Prompt` trait to `nu_ansi_term::Color` exclusively, and
nushell/reedline#1112, which adds typed inherent
methods and a JSON filter to `SqliteBackedHistory`.

Despite nushell/reedline#1128 being a breaking
change, nushell needs no source changes. `NushellPrompt` only ever used
the defaulted `get_*_color` methods, so the new return type has no
effect here.

## User-facing changes (Release notes)
<!--
This section is used (mostly as-is) for https://www.nushell.sh/blog/

Describe how Nushell behavior changes from a user's perspective.
Do NOT describe internal Rust changes here.

Write in a release note style, for example:
- "Added support for..."
- "Fixed an issue where..."
- "Nushell now supports..."
- "Improved performance of..."

If your changes do NOT affect users (internal refactors, cleanup, etc.),
just write:
- "n/a"
- "nan"
- or similar

This tells us the change should not appear in the changelog.

Tips:
- Focus on observable behavior
- Include examples if helpful
- Keep it concise

You can:
- Write a short paragraph (will appear as a bullet point), OR
- Use headings (###) if your change needs more structure

Avoid writing things like:
- "In this PR, I refactored..."
- "This updates internal code..."

You may leave this blank until the PR is ready.
-->

## Additional notes
<!--
Optional.

Examples:
- fixes #123
- closes #456
- related #789

Anything else reviewers should know.
Remove this section if not needed.
-->
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