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
Detect background color and use a light theme as appropriate #464
Can we turn this into a request for PSReadline to detect the background and choose an appropriate default set of colors -- unless they have been set by the user?
For that matter, is there any chance that we could get PSReadline to use some sort of configuration file rather than needing a long profile script to set all the colors? Especially now that we have (potentially) access to 256 xterm colors or even 16bit full color, and/or support for bold, etc...
Yellow on white is not right,
Nor is blue on black.
Wise color choices are great.
Power Shell command background seems to take on the value of the most recently used color of the screen background.
Discovered this by accident.
I can see my yellow commands against a darker background. I was using white as my background, then I changed it to a darker green, too dark, so I lightened it up to a nice shade of blue. Screen Snippet attached ,
PS_Yellow_command_letters_on_dark_background.png.
Now that I have something that is workable, but not great, I am afraid to tweak it more, have to move on to more urgent work.
Major Minor Build Revision
It looks like it is possible to detect the background color on CentOS and possibly other systems, see here. This will make it possible to create light and dark themes.
changed the title [-]the default typing color for text is yellow in centos, barely visible[/-][+]Detect background color and use a light theme as appropriate[/+]on Nov 4, 2017
changing the background color to the default dark blue it has on windows would solve the issue. the issue here is $Host.UI.RawUI.BackgroundColor only takes colors of "System.ConsoleColor" which does not have this very blue. if pwsh would default to this background color (on linux) would be a huge win for every user.
If PSRL changed my terminal/console color from my preferred color scheme, I wouldn't be too happy with that.
I totally understand your point. but I am more annoyed when I cannot read/use pwsh. I would prefer a default that works - that can be changed to personal preferences. rather than having to figure out why one cannot read/work with pwsh and how to change it to be readable. especially for new users this feels like a huge gap.
I think one way to solve this is to have themes support which includes the background color. You can set it once in your profile. It doesn't seem there is a universal way to programmatically get the current background color across all distros/OS's so I don't think we should try to solve that problem. We can start with dark, light, and Windows PowerShell themes.
Console themes are a mess. Add in Windows PowerShell's weird custom color scheme, and it's a nearly unfixable mess.
On Windows, traditionally, you can set the 16-color palette using proprietary APIs -- which is why PSConsoleTheme et. al. are Windows-only. The current beta of Pansies has (Windows-only) themes that use those Windows-only APIs and include support for PSReadLine and the PowerShell default error/warning colors, etc. They work fine, but ...
There is no way to make that cross-platform yet.
The only way there ever will be, is to use the OSC escape sequences to set the console palette, but that would require full implementations of OSC4, OSC10 and OSC11 on Windows and on all the third-party terminals you wanted to support. We need all three to be able to to set the palette and choose the default foreground and background colors -- additionally, we would need QUERY support to be able to detect the background color without explicitly setting it.
Unfortunately, that support just isn't there in most places. According to the superuser threadJason Shirk (@lzybkr) linked earlier, they work in some versions of xTerm, but they don't work in the default Ubuntu terminal. On Windows (even in tmux) only the OSC4 is implemented, but without query support and with no documentation (well, one of my teammates added some documentation for Windows, but it's just what we were able to discover on our own).
Without query support, and with no way to set the default background and foreground, we would just have to assume that the background is 0 (black), and foreground is 15 (white) -- which results in really awful, pink backgrounds with yellow text in the default Windows PowerShell window, because it abused those color indexes for it's dark blue background and light gray foreground instead of using the actual dark blue and light gray color indexes.
Importantly, this is terminal-specific.
Even without taking operating systems into account, there's no way to change or detect the 16-color palette that works reliably across terminal apps. On Windows 10 the new escape sequences work on the same level as the APIs, so they have no effect in ConEmu or Console2 or Hyper ... each of which has it's own way to handle it. On Linux and Mac different terminals have different implementations -- as you can see on the superuser thread 😖
Reacted by Mr Beedell, Roke Julian Lockhart and sharpchen
For what it's worth, my intention is to alter the theme support in PANSIES with support for sending the escape sequences on non-Windows platforms, in hopes that they'll work cross-platform. I may also take that functionality into a separate module, because themes don't necessarily need Windows 10 or RGB support 😉
Just encountered that issue using PowerShell Core 7.1.1 on Windows Terminal with Solarized Light theme (slightly customized). Syntax is highlighted with yellow and isn't visible at all.
This is how [System.Reflection.AssemblyName]::GetAssemblyName($PathToAssembly).FullName looks like
Update:
Fixed by editing %userprofile%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 and choosing colors looking nice on my terminal schema, but it still would be nice to add support for light schemes out of the box.
Tried it on a fresh Mac OS install with a white terminal background, PS cmdlets are yellow, .NET classes are pale grey and their properties are an even paler grey - it's pretty unusable!
Activity
lzybkr commentedon Nov 9, 2016
From sergei (@vors) on September 5, 2016 18:47
Does it look like these screenshots #1036 ?
lzybkr commentedon Nov 9, 2016
From garegin16 on September 5, 2016 20:6
Yes. It's even worse on my screen. It looks bright yellow. I can't see anything
lzybkr commentedon Nov 9, 2016
From sergei (@vors) on September 5, 2016 20:9
Can you post a screenshot?
As a workaround, you can set background color to black or anything dark.
lzybkr commentedon Nov 9, 2016
From Joel Bennett (@Jaykul) on September 6, 2016 0:35
Can we turn this into a request for PSReadline to detect the background and choose an appropriate default set of colors -- unless they have been set by the user?
For that matter, is there any chance that we could get PSReadline to use some sort of configuration file rather than needing a long profile script to set all the colors? Especially now that we have (potentially) access to 256 xterm colors or even 16bit full color, and/or support for bold, etc...
Yellow on white is not right,
Nor is blue on black.
Wise color choices are great.
lzybkr commentedon Nov 9, 2016
From David R. Williamson (@drwill-ms) on September 17, 2016 2:13
Same for me on OSX. Very bright yellow text on a white background. Only text I type.
lzybkr commentedon Nov 9, 2016
From garegin16 on September 18, 2016 2:59
Huh. It didn't do that on my os x install. The text is black by default.
Sent from my iPhone
lzybkr commentedon Nov 9, 2016
From Steve Lee (@SteveL-MSFT) on November 1, 2016 19:2
Joel Bennett (@Jaykul) I like your suggestion, can you open an issue in http://github.com/lzybkr/psreadline
lzybkr commentedon Nov 9, 2016
From fnvogt1954 on November 5, 2016 15:46
Power Shell command background seems to take on the value of the most recently used color of the screen background.

Discovered this by accident.
I can see my yellow commands against a darker background. I was using white as my background, then I changed it to a darker green, too dark, so I lightened it up to a nice shade of blue. Screen Snippet attached ,
PS_Yellow_command_letters_on_dark_background.png.
Now that I have something that is workable, but not great, I am afraid to tweak it more, have to move on to more urgent work.
Major Minor Build Revision
5 1 14393 206
lzybkr commentedon Nov 4, 2017
It looks like it is possible to detect the background color on CentOS and possibly other systems, see here. This will make it possible to create light and dark themes.
[-]the default typing color for text is yellow in centos, barely visible[/-][+]Detect background color and use a light theme as appropriate[/+]milindsaraswala commentedon Aug 23, 2018
I am late to the party but I found the article which make your mac terminal window same like windows PowerShell. By Setting Profile. Please follow this below article
https://info.sapien.com/index.php/quickguides/setting-up-powershell-on-your-mac
gpunktschmitz commentedon Nov 11, 2018
changing the background color to the default dark blue it has on windows would solve the issue. the issue here is
$Host.UI.RawUI.BackgroundColoronly takes colors of "System.ConsoleColor" which does not have this very blue. if pwsh would default to this background color (on linux) would be a huge win for every user.rkeithhill commentedon Nov 11, 2018
If PSRL changed my terminal/console color from my preferred color scheme, I wouldn't be too happy with that.
gpunktschmitz commentedon Nov 11, 2018
I totally understand your point. but I am more annoyed when I cannot read/use pwsh. I would prefer a default that works - that can be changed to personal preferences. rather than having to figure out why one cannot read/work with pwsh and how to change it to be readable. especially for new users this feels like a huge gap.
SteveL-MSFT commentedon Nov 11, 2018
I think one way to solve this is to have themes support which includes the background color. You can set it once in your profile. It doesn't seem there is a universal way to programmatically get the current background color across all distros/OS's so I don't think we should try to solve that problem. We can start with dark, light, and Windows PowerShell themes.
lzybkr commentedon Nov 12, 2018
I think theme support would be great, but I wonder if that belongs in PSReadLine or elsewhere.
Note there are other projects introducing themes, e.g. https://github.com/mmims/PSConsoleTheme and maybe Joel Bennett (@Jaykul) has something else.
SteveL-MSFT commentedon Nov 12, 2018
It would make sense to be separate if it works independently and cross-platform. Unfortunately,
PSConsoleThemeis currently Windows only.Jaykul commentedon Nov 26, 2018
Console themes are a mess. Add in Windows PowerShell's weird custom color scheme, and it's a nearly unfixable mess.
On Windows, traditionally, you can set the 16-color palette using proprietary APIs -- which is why PSConsoleTheme et. al. are Windows-only. The current beta of Pansies has (Windows-only) themes that use those Windows-only APIs and include support for PSReadLine and the PowerShell default error/warning colors, etc. They work fine, but ...
There is no way to make that cross-platform yet.
The only way there ever will be, is to use the
OSCescape sequences to set the console palette, but that would require full implementations ofOSC4,OSC10andOSC11on Windows and on all the third-party terminals you wanted to support. We need all three to be able to to set the palette and choose the default foreground and background colors -- additionally, we would need QUERY support to be able to detect the background color without explicitly setting it.Unfortunately, that support just isn't there in most places. According to the superuser thread Jason Shirk (@lzybkr) linked earlier, they work in some versions of xTerm, but they don't work in the default Ubuntu terminal. On Windows (even in tmux) only the
OSC4is implemented, but without query support and with no documentation (well, one of my teammates added some documentation for Windows, but it's just what we were able to discover on our own).Without query support, and with no way to set the default background and foreground, we would just have to assume that the background is 0 (black), and foreground is 15 (white) -- which results in really awful, pink backgrounds with yellow text in the default Windows PowerShell window, because it abused those color indexes for it's dark blue background and light gray foreground instead of using the actual dark blue and light gray color indexes.
Importantly, this is terminal-specific.
Even without taking operating systems into account, there's no way to change or detect the 16-color palette that works reliably across terminal apps. On Windows 10 the new escape sequences work on the same level as the APIs, so they have no effect in ConEmu or Console2 or Hyper ... each of which has it's own way to handle it. On Linux and Mac different terminals have different implementations -- as you can see on the superuser thread 😖
Jaykul commentedon Nov 26, 2018
For what it's worth, my intention is to alter the theme support in PANSIES with support for sending the escape sequences on non-Windows platforms, in hopes that they'll work cross-platform. I may also take that functionality into a separate module, because themes don't necessarily need Windows 10 or RGB support 😉
uladz-zubrycki commentedon Feb 8, 2021
Just encountered that issue using PowerShell Core 7.1.1 on Windows Terminal with Solarized Light theme (slightly customized). Syntax is highlighted with yellow and isn't visible at all.
This is how

[System.Reflection.AssemblyName]::GetAssemblyName($PathToAssembly).FullNamelooks likeUpdate:
Fixed by editing
%userprofile%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1and choosing colors looking nice on my terminal schema, but it still would be nice to add support for light schemes out of the box.Skuldo commentedon Apr 1, 2021
Tried it on a fresh Mac OS install with a white terminal background, PS cmdlets are yellow, .NET classes are pale grey and their properties are an even paler grey - it's pretty unusable!
JustPlayground commentedon Dec 1, 2025
Almost 10 years.