I want to change color of first console statement from yellow to some another color because it looks bad on a white background. How can i do this ?
You can specify the color of text by using the ForegroundColor parameter, and you can specify the background color by using the BackgroundColor parameter. The Separator parameter lets you specify a string to use to separate displayed objects.
The ${} notation actually has two uses; the second one is a hidden gem of PowerShell: That is, you can use this bracket notation to do file I/O operations if you provide a drive-qualified path, as defined in the MSDN page Provider Paths.
As mentioned earlier, Windows PowerShell console displays white on blue by default and red on black for error messages, so to change colors, right-click on the PowerShell Window top-bar, and select 'Properties'.
The syntax highlighting comes from PSReadLine
. To set the foreground color for Command
tokens (which shows in yellow by default), use Set-PSReadLineOption
:
Set-PSReadlineOption -TokenKind Command -ForegroundColor DarkGreen
Place that statement in your $profile
to have it run every time you launch PowerShell:
'Set-PSReadlineOption -TokenKind Command -ForegroundColor DarkGreen' |Add-Content $Profile
Update: Use this command instead for newer versions:
Set-PSReadLineOption -Colors @{ Command = 'Red' }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With