Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
SteveL-MSFT opened this issue Oct 25, 2022 · 5 comments · Fixed by #9539
Closed
2 tasks done
Assignees
Labels
area-conceptual Area - Conceptual articles issue-doc-idea Issue - request for new content

Comments

@SteveL-MSFT
Copy link
Contributor

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

@sdwheeler
Copy link
Contributor

@SteveL-MSFT Do you have some sample themes we can document?

@sdwheeler sdwheeler added needs-more-info Waiting - for more information and removed needs-triage Waiting - Needs triage labels Oct 25, 2022
@DHowett
Copy link

DHowett commented Nov 8, 2022

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. 😄

@sdwheeler sdwheeler self-assigned this Dec 6, 2022
@sdwheeler
Copy link
Contributor

sdwheeler commented Dec 6, 2022

@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

@sdwheeler sdwheeler added area-conceptual Area - Conceptual articles and removed needs-more-info Waiting - for more information labels Dec 7, 2022
sdwheeler added a commit that referenced this issue Dec 7, 2022
* Add article about using light themes

* Fix broken link

* fix typos

* Apply suggestions from code review

Co-authored-by: Mikey Lombardi (He/Him) <michael.t.lombardi@gmail.com>

* Editorial changes

Co-authored-by: Mikey Lombardi (He/Him) <michael.t.lombardi@gmail.com>
@DHowett
Copy link

DHowett commented Dec 8, 2022

@sdwheeler hey, those look really good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-conceptual Area - Conceptual articles issue-doc-idea Issue - request for new content
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants