Skip to content

Doc to help users set PSReadLine colors and PowerShell colors for light themed terminal #9358

Closed

Description

Prerequisites

  • Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Document new Get-Foo cmdlet" instead of "New cmdlet."

PowerShell Version

7.3

Summary

The default colors for both PowerShell and PSReadLine are built expecting a dark background. However, some users may choose to use a light background with dark text. However, most of the default colors don't set the background, so in some cases the light foreground with the light background makes that text invisible. Users may not be aware they can change their colors to make the text visible. It seems we should just have some sample PS script for setting colors appropriate for light themed terminals they can then put in their $profile.

Not sure if it makes sense to have this as part of the ANSI topic or separate as users would need to know about ANSI to find it.

Details

No response

Proposed Content Type

About Topic

Proposed Title

No response

Related Articles

No response

Activity

  1. sdwheeler commented on Oct 25, 2022

    @sdwheeler
    Contributor

    Steve Lee (@SteveL-MSFT) Do you have some sample themes we can document?

  2. DHowett commented on Nov 8, 2022

    @DHowett

    For what it's worth, I wholeheartedly believe that the DefaultTokenColor, TypeColor and ContinuationPromptColor should be \e[39m. In almost all default color schemes on many terminals that color is the same as white (on dark-theme terminals) so it doesn't present too much of a compatibility issue. At the same time, it opens up the possibility that PSReadline automatically performs better on light-theme terminals. The cost is so low¹ and the benefit is so great² that we'd be remiss in not considering it.

    ¹ Terminals that do not support 39 and 49 are rare in the wild. Even the Windows Console supports it in its earliest versions. To quote PowerShell/PSReadLine#1626:

    I went back to the Windows source code and confirmed: conhost supports 39;49 everywhere ENABLE_VIRTUAL_TERMINAL_PROCESSING is supported.

    ² The benefit is, "nobody will ever complain about this again." That doesn't even account for all the people who just leave or change shells or never learn that there is documentation telling them the "right" way to "fix" it. 😄

  3. sdwheeler commented on Dec 6, 2022

    @sdwheeler
    Contributor

    Dustin L. Howett (@DHowett) What do you think of these colors for a light theme? Most of these colors come directly from the ISE's light-mode configuration.

    $PSROptions = @{
        Colors  = @{
            Command                  = $PSStyle.Foreground.FromRGB(0x0000FF)
            Comment                  = $PSStyle.Foreground.FromRGB(0x006400)
            ContinuationPrompt       = $PSStyle.Foreground.FromRGB(0x0000FF)
            Default                  = $PSStyle.Foreground.FromRGB(0x0000FF)
            Emphasis                 = $PSStyle.Foreground.FromRGB(0x287BF0)
            Error                    = $PSStyle.Foreground.FromRGB(0xE50000)
            InlinePrediction         = $PSStyle.Foreground.FromRGB(0x93A1A1)
            Keyword                  = $PSStyle.Foreground.FromRGB(0x00008b)
            ListPrediction           = $PSStyle.Foreground.FromRGB(0x06DE00)
            Member                   = $PSStyle.Foreground.FromRGB(0x000000)
            Number                   = $PSStyle.Foreground.FromRGB(0x800080)
            Operator                 = $PSStyle.Foreground.FromRGB(0x757575)
            Parameter                = $PSStyle.Foreground.FromRGB(0x000080)
            String                   = $PSStyle.Foreground.FromRGB(0x8b0000)
            Type                     = $PSStyle.Foreground.FromRGB(0x008080)
            Variable                 = $PSStyle.Foreground.FromRGB(0xff4500)
            ListPredictionSelected   = $PSStyle.Background.FromRGB(0x93A1A1)
            Selection                = $PSStyle.Background.FromRGB(0x00BFFF)
        }
    }
    Set-PSReadLineOption @PSROptions
  4. added a commit that references this issue on Dec 7, 2022
    36883e8
  5. DHowett commented on Dec 8, 2022

    @DHowett

    Sean Wheeler (@sdwheeler) hey, those look really good!

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions