Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off syntax highlighting in console?

I just want PowerShell to be black text on a white background. However, PowerShell v5 highlights my commands and makes them yellow, which is impossible to see. Is there a way to turn off ALL syntax highlighting in PowerShell?

like image 639
Simonxca Avatar asked Feb 06 '16 21:02

Simonxca


People also ask

How do I turn on syntax highlighting?

After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.

How do I turn off color in vi?

You can change color schemes at anytime in vi by typing colorscheme followed by a space and the name of the color scheme. For more color schemes, you can browse this library on the vim website. You can enable or disable colors by simply typing "syntax on" or "syntax off" in vi.


1 Answers

Syntax coloring in PowerShell v5 can be modified via Set-PSReadlineOption. The following command sets the foregound and background color for comments to the shell foreground and background color:

Set-PSReadlineOption -TokenKind Comment -ForegroundColor $Host.UI.RawUI.ForegroundColor -BackgroundColor $Host.UI.RawUI.BackgroundColor

or just black and white:

Set-PSReadlineOption -TokenKind Comment -ForegroundColor Black -BackgroundColor White

You need to do this for all TokenKind values to remove syntax coloring entirely.

If you also want to change output stream colors you can do that via the properties of the host's PrivateData object:

$Host.PrivateData.WarningForegroundColor = $Host.UI.RawUI.ForegroundColor
$Host.PrivateData.WarningBackgroundColor = $Host.UI.RawUI.BackgroundColor
...

Put all of these statements into your profile to get them applied every time you start PowerShell, e.g.:

$HOME\Documents\WindowsPowerShell\profile.ps1
like image 98
Ansgar Wiechers Avatar answered Sep 17 '22 16:09

Ansgar Wiechers