PowerShell: Output of `ls` or ` Get-ChildItem` has unexpected bg color for directories names
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Hello pwsh team,
Please check the screenshot below:
I have empty profile file under Documents\PowerShell\Microsoft.PowerShell_profile.ps1
also no modules under Documents\PowerShell\Modules\
.
Could you please tell me where else should i check for such configuration?
Thanks
Expected behavior
Directories names has a transparent background color
Actual behavior
Directories names has a blue background color
Error details
No response
Environment data
PS C:\Program Files> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.0
PSEdition Core
GitCommitId 7.3.0
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 11
- Comments: 16 (3 by maintainers)
Configure
$PSStyle
For example white directory color:Rephrasing out what was said above, for someone who is being bothered by this and is landing here out of the blue, and doesn’t quite grasp what is happening, hoping that it is a bit more clear.
I found it a bit perplexing that a change like this was added, as the default behavior. Maybe there was a lot of people asking for it. Anyway, changing the background color of folders is just one of the options, it is actually pretty cool what can be done with PSStyle. I’ve found this blog post pretty good, explaining some neat things you can do.
You will discover some other colouring applied to items in directory output - which you probably don’t want either
Is a useful add on to many profiles. The powers that be believe most people want their directories to be blue because bash makes them blue, but it blue on black breaks the accessibility requirements for contrast so they have selected white on blue. A search should find the discussion on this. The important thing is you can set things exactly how you want them to be.
This did not work well for me - apparently missed this change and just thought it was broken.
Unclear why this is closed? Is it being fixed in new version?
I have a problem reading things when there is movement, unexpected colours and a few other things on the screen, and find unix/linux seemingly random use of colours makes it much more difficult to read. There is a demand from people coming from other shells to be able to get the same colours, in particular “blue” for directory. However blue text on black fails accessibility tests for people with more common eyesight problems - who need more contrast, hence this compromise. A decision was “what seemed like a good idea to a dev at the time” colours to be opt out rather than opt in, so that people would know colour was available. I still contend that finding the opt out leaves a few people who want it off frothing-at-the-mouth angry, where an opt in would have left those who missed their linux colours feeling mild disappointment… however that argument was lost long ago. I turn it off in my profile, and if I need to test with
-noprofile
I work with slight nausea and the reading speed of a small child 😦@garretwilson the to turn all the colours off you can set $PSStyle.OutputRendering = “PlainText”
Otherwise the noticeable update in 7.3 is that
$psstyle.FileInfo.Directory
,$psstyle.FileInfo.Executable
and$psstyle.FileInfo.SymbolicLink
now contain escape sequences for Directories links and executables. You can choose your own if you don’t like the PowerShell team’s choice, I find none at all is best.For other items
$PSStyle.FileInfo.Extension
holds the file extension and the escape sequence.Clear()
removes them all.$PSStyle.FileInfo.Extension.Add(".JPG","$($PSStyle.Foreground.BrightCyan)")
adds one. Again I find clear() gives the optimal combinations.If you don’t like column headings and list labels in green then
$PSStyle.Formatting.TableHeader
and$PsStyle.Formatting.FormatAccent
contain the ansi sequence for those and I find that no-sequence is better for meAs with so much, it’s very customizable if (like me) you don’t like the defaults.