You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ssh <start typing hostname> --- the hostname is invisible. No matter what color scheme I select. #14242
Just open a windows terminal and issue a ssh command.
(also seen when I ran [environment]::OsVersion -- the [environment] part of the string is invisible)
Expected Behavior
Here is the copy/paste of what I typed into the terminal (and what came back when I hit enter)
PS C:\Users\migarret\Work Folders\Downloads> ssh imola1
Warning: Permanently added 'xx.xx.xx.xx' (ED25519) to the list of known hosts.
Last login: Mon Oct 17 15:20:33 2022 from xx.xx.xx.xx
AvereOS_2022.08.0
237dmitry you're right that it's configurable, but also... this text should be showing up in the "default foreground" color. I marked your original comments as off-topic since they may confuse users into thinking that to see text by default they would need to do some configuring. Still, I appreciate you adding additional info to this bug report!
The default foreground and background in every color scheme should absolutely be readable and require no Terminal or shell configuration. 🙂
PS C:\Users\migarret\Work Folders\Downloads> Get-PSReadlineOptions
Get-PSReadlineOptions : The term 'Get-PSReadlineOptions' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-PSReadlineOptions
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-PSReadlineOptions:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\migarret\Work Folders\Downloads> Set-PSReadLineOption -Color @{'Default' = "`e[38;5;16m"}
Set-PSReadLineOption : 'e[38;5;16m' is not a valid color value. It must be a ConsoleColor, ANSI escape sequence, or RGB value with optional leading '#'.
At line:1 char:1
+ Set-PSReadLineOption -Color @{'Default' = "`e[38;5;16m"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-PSReadLineOption], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.SetPSReadLineOption
Alright, so the root cause for this one is that the white color¹ in your default color scheme, Campbell, is set to the same color as the background. Now, you told me that this worked before Terminal 1.15 . . . and I'll get to that.
Anyway, PowerShell is explicitly requesting white and it doesn't know that your background is also white. Crap.
We've got a couple ways around this.
One is this feature that's currently available in preview builds that automatically detects when two colors have poor (or even catastrophic!) contrast and darkens or lightens the foreground color as appropriate to make it visible. Eventually, we'll enable it by default. That re-landed in #13343 and was enhanced in #13512.
The other is for you to change the white color (and bright white) to be dark; effectively, make a flipped version of the Campbell scheme where white and black are actually swapped.
¹ that is, color 37. you can see in your PSReadlineOptions that DefaultTokenColor is (blah blah blah) **37** m
² why it's asking for 37 is... a long and ultimately disappointing story. The console only used to support 16 colors but all terminals since, say, 1981 have supported 18. PowerShell used the tools available to them and declared the "default" token color to be "white" (rather than "let the terminal decide what is best for visibility")
Now for the kicker. This worked in Terminal 1.14 (actually, this worked in all versions of Terminal between 0.1 (inclusive) and 1.15 (exclusive)!) In 1.15, however, we tore off in PR #13352 a band-aid that we had previously applied to PowerShell (originally applied in #6810).
Well, that band-aid was fixing two problems. One, the actual problem. Two, this.
We expressly ignored any requests for CSI 40 (black background) and CSI 37 (white foreground) from PowerShell... because they used it erroneously all the time.
In so doing, we hid this issue where their default token color is, in fact, 37. It should be 39.
Now that we're respecting PowerShell's color choices again, we're bound to run into more cases like this.
Mike Garrett (@mgarrett69) realized that he never tested other color schemes because of our poor and confusing UI for selecting/editing them. 1.16 didn't do so much to help, because the buttons that make it clear that there's actions to take are "below the fold." We should keep ideating there.
We talked more with the PsReadline folks today. overall, we felt like the best option wasn't to keep patching an edge case with more heuristics. That would just shift the dissatisfaction around to different users in an elaborate game of wack-a-mole. They acknowledged that yea, the default PsReadline settings aren't configured for a light scheme, they're set up for a dark scheme (for more historical context: PowerShell/PSReadLine#464). They're gonna go ahead and update their docs to better clarify that users who prefer a light scheme should change their PsReadLine settings to match. That's tracked in: MicrosoftDocs/PowerShell-Docs#9358
As an immediate workaround, you should be able to set "adjustIndistinguishableColors": "indexed" to force the Terminal to manually adjust the text colors to ensure there's enough contrast in this use case.
Activity
DHowett commentedon Oct 17, 2022
Huh. This might be an alternate reality version of this note, which applies to background colors (they're handled by the same code.)
All the same, can you share your
settings.json?DHowett commentedon Oct 17, 2022
(And, perhaps, would you grab the following powershell output?
237dmitry commentedon Oct 17, 2022
The main trouble is in the PSReadline options and $PSStyle parameters that know nothing about colorschemes. Everything requires configuration.
Select with the mouse or set it to the clipboard:
You can change default foreground color of PSReadline:
DHowett commentedon Oct 17, 2022
237dmitry you're right that it's configurable, but also... this text should be showing up in the "default foreground" color. I marked your original comments as off-topic since they may confuse users into thinking that to see text by default they would need to do some configuring. Still, I appreciate you adding additional info to this bug report!
The default foreground and background in every color scheme should absolutely be readable and require no Terminal or shell configuration. 🙂
237dmitry commentedon Oct 17, 2022
I think, PSReadline Team does not think about it. If you launch pwsh without profile
pwsh -NoProfileand see output ofGet-PSReadlineOptionsthere is:I do not know this parameter changes depend on base 16 colors or not. Rather not. This is static value -- user knows better how to tune host.
DHowett commentedon Oct 17, 2022
Ah, that's a very good point! The default configuration of PowerShell does display white-on-default-bg. Bah. Thank you!
mgarrett69 commentedon Oct 18, 2022
settings.zip
mgarrett69 commentedon Oct 18, 2022
mgarrett69 commentedon Oct 18, 2022
Let me know if I missed any of the output you wanted. As you can see, I caught errors when trying a few of the suggestions above.
And, for what it's worth, my background is grey, so even white lettering should not be invisible,,, I think.
elsaco commentedon Oct 19, 2022
Mike Garrett (@mgarrett69) it's
Get-PSReadLineOptionnotGet-PSReadLineOptionsmgarrett69 commentedon Oct 20, 2022
Thanks elsaco
PS C:\Users\migarret\Work Folders\Downloads> Get-PSReadLineOption
EditMode : Windows
AddToHistoryHandler : System.Func`2[System.String,System.Object]
HistoryNoDuplicates : True
HistorySavePath : C:\Users\migarret\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
HistorySaveStyle : SaveIncrementally
HistorySearchCaseSensitive : False
HistorySearchCursorMovesToEnd : False
MaximumHistoryCount : 4096
ContinuationPrompt : >>
ExtraPromptLineCount : 0
PromptText : {> }
BellStyle : Audible
DingDuration : 50
DingTone : 1221
CommandsToValidateScriptBlockArguments : {ForEach-Object, %, Invoke-Command, icm...}
CommandValidationHandler :
CompletionQueryItems : 100
MaximumKillRingCount : 10
ShowToolTips : True
ViModeIndicator : None
WordDelimiters : ;:,.[]{}()/|^&*-=+'"–—―
AnsiEscapeTimeout : 100
CommandColor : "$([char]0x1b)[93m"
CommentColor : "$([char]0x1b)[32m"
ContinuationPromptColor : "$([char]0x1b)[37m"
DefaultTokenColor : "$([char]0x1b)[37m"
EmphasisColor : "$([char]0x1b)[96m"
ErrorColor : "$([char]0x1b)[91m"
KeywordColor : "$([char]0x1b)[92m"
MemberColor : "$([char]0x1b)[97m"
NumberColor : "$([char]0x1b)[97m"
OperatorColor : "$([char]0x1b)[90m"
ParameterColor : "$([char]0x1b)[90m"
SelectionColor : "$([char]0x1b)[30;47m"
StringColor : "$([char]0x1b)[36m"
TypeColor : "$([char]0x1b)[37m"
VariableColor : "$([char]0x1b)[92m"
DHowett commentedon Oct 20, 2022
Alright, so the root cause for this one is that the
whitecolor¹ in your default color scheme, Campbell, is set to the same color as thebackground. Now, you told me that this worked before Terminal 1.15 . . . and I'll get to that.Anyway, PowerShell is explicitly requesting
whiteand it doesn't know that your background is also white. Crap.We've got a couple ways around this.
One is this feature that's currently available in preview builds that automatically detects when two colors have poor (or even catastrophic!) contrast and darkens or lightens the foreground color as appropriate to make it visible. Eventually, we'll enable it by default. That re-landed in #13343 and was enhanced in #13512.
The other is for you to change the
whitecolor (and bright white) to be dark; effectively, make a flipped version of the Campbell scheme where white and black are actually swapped.¹ that is, color
37. you can see in your PSReadlineOptions thatDefaultTokenColoris(blah blah blah) **37** m² why it's asking for
37is... a long and ultimately disappointing story. The console only used to support 16 colors but all terminals since, say, 1981 have supported 18. PowerShell used the tools available to them and declared the "default" token color to be "white" (rather than "let the terminal decide what is best for visibility")Now for the kicker. This worked in Terminal 1.14 (actually, this worked in all versions of Terminal between 0.1 (inclusive) and 1.15 (exclusive)!) In 1.15, however, we tore off in PR #13352 a band-aid that we had previously applied to PowerShell (originally applied in #6810).
Well, that band-aid was fixing two problems. One, the actual problem. Two, this.
We expressly ignored any requests for CSI
40(black background) and CSI37(white foreground) from PowerShell... because they used it erroneously all the time.In so doing, we hid this issue where their default token color is, in fact,
37. It should be39.Now that we're respecting PowerShell's color choices again, we're bound to run into more cases like this.
Mike Garrett (@mgarrett69) realized that he never tested other color schemes because of our poor and confusing UI for selecting/editing them. 1.16 didn't do so much to help, because the buttons that make it clear that there's actions to take are "below the fold." We should keep ideating there.
Tagged for team discussion so we can assess:
zadjii-msft commentedon Oct 25, 2022
We talked more with the PsReadline folks today. overall, we felt like the best option wasn't to keep patching an edge case with more heuristics. That would just shift the dissatisfaction around to different users in an elaborate game of wack-a-mole. They acknowledged that yea, the default PsReadline settings aren't configured for a light scheme, they're set up for a dark scheme (for more historical context: PowerShell/PSReadLine#464). They're gonna go ahead and update their docs to better clarify that users who prefer a light scheme should change their PsReadLine settings to match. That's tracked in: MicrosoftDocs/PowerShell-Docs#9358
As an immediate workaround, you should be able to set
"adjustIndistinguishableColors": "indexed"to force the Terminal to manually adjust the text colors to ensure there's enough contrast in this use case.