Skip to content

Make prompt colors configurable - #18003

Closed
Dominik Kowalski (dkaszews) wants to merge 19 commits into
PowerShell:masterfrom
dkaszews:dkaszews-psstyle-prompt
Closed

Dominik Kowalski (dkaszews) wants to merge 19 commits into
PowerShell:masterfrom
dkaszews:dkaszews-psstyle-prompt

Conversation

@dkaszews

@dkaszews Dominik Kowalski (dkaszews) commented Aug 31, 2022 •

Copy link
Copy Markdown
Contributor

PR Summary

Allows user to configure prompt colors (e.g. when removing non-empty directories or explicitly giving -Confirm flag). The configurable colors and the default values are as following (up to discussion):

  • Caption - bold yellow, same as warnings
  • Message - default (reset)
  • Help - default (reset)
  • Choice selected by default - white on blue
  • Choice not selected by default - blue
  • Choice for help - default (reset)

Changes in resource strings to avoid coloring trailing whitespace, which leads to visual artifacts for background colors.

Test had to be written by forking the powershell executable, as I could find no other way to both allow interactive prompt (disqualifies [System.Management.Automation.PowerShell] even with test hooks) and capture output from Write(Line)ToConsole (disqualifies regular invocation, even with test hooks). Test is tagged slow because it takes up to 100 times longer than similar tests using [System.Management.Automation.PowerShell] (80ms vs 8s), but if this method is too janky to use in CI, I can simply remove it and mark PR as "can only be tested interactively".

Closes #17961

PR Context

Existing colors are hardcoded and are either yellow+white when on light background, or blue+black on white background. Because it is not really possible to reliably detect background colors, especially considering remoting over PSSession or ssh, or embedding sessions in screen or tmux, this leads to white text on white background, completely invisible.

Without PR:
image

With PR (defaults):
image

With PR (custom):
image

PR Checklist

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Large WG-Interactive-Console the console experience WG-NeedsReview Needs a review by the labeled Working Group

Projects

Development

Successfully merging this pull request may close these issues.

Prompt colors not configurable, not visible on white background