-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Weird foreground color issue with Cmder + PowerShell Core #1899
Comments
Having the same issue myself on Windows 10 October update |
Same issue here. This is a problem on two separate machines of mine after updating with v1809 of Win10. |
Ditto. After updating to the latest Windows 10 release, the foreground color is green both with PS5 and PS6. |
The workaround I will use involves a unicode no width char:
|
Could you guys tell me if this issue would be gone after installing PSReadLine v1.2: Install-Module -Name PSReadLine -RequiredVersion 1.2 -Scope CurrentUser -Force -SkipPublisherCheck I guess it's a likely a complex issue of PSReadLine2 and Cmder, maybe related to PowerShell/PSReadLine#818. Besides, thanks @mattvperry for the workaround! 👍 |
@h404bi This seems to have fixed it for me. |
Thanks for the report, @refactorsaurusrex – it helped me fix two of my problems in one go. First, the color, and second, the absence of "PS" before the prompt. I added the third line, seen below, to the code: [ScriptBlock]$CmderPrompt = {
$Host.UI.RawUI.ForegroundColor = "White"
Microsoft.PowerShell.Utility\Write-Host "PS " -NoNewline # <!-- this line is added
Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
checkGit($pwd.ProviderPath)
} |
Purpose of the issue
Description of the issue
Out of the box, running PowerShell with Cmder sets the foreground color to white:
Today I installed PowerShell Core and created a new Cmder task exactly like the default 'PowerShell as Admin task', but points to
pwsh.exe
instead ofPowershell.exe
:*C:\Program Files\PowerShell\6\pwsh.exe -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''"
For reasons I don't understand, the foreground color for the PowerShell Core window is green:
While trying to understand why, I spent some time fiddling with the following block of code contained in
\vendor\profile.ps1
:Here's where it gets weird. If I change that
Write-Host
statement to use-ForegroundColor White
instead ofGreen
, the foreground color remains permanently white. If I change it toRed
, the foreground color remains permanently red. Even weirder: If I leave the originalWrite-Host
statement alone (using the originalGreen
color), but add an additionalWrite-Host
statement above it without aForegroundcolor
parameter, the foreground color remains white. It's as though aWrite-Host
statement is required in order to maintain the state of$Host.UI.RawUI.ForegroundColor
.Anyone else experiencing this oddity? Am I missing something stupid?
I tried this with Cmder 1.3.5 and 1.3.6 - same result.
Additional Examples:
Results in
white
foreground color:Also results in
white
foreground color:Results in
red
foreground color:The text was updated successfully, but these errors were encountered: