5

I recently upgraded a Windows 8.1 computer I had to Windows 10, which comes with PowerShell 5.0 by default. I noticed that PowerShell now has syntax coloring for keywords, cmdlets, strings, etc.:

enter image description here

I was wondering if there is any way to set a custom color scheme? For example, comments are currently green and I'd like to make them gray. Is this possible?

  • Also note, this feature is available in older powershells with the installation of the PSReadline module. – Eris Aug 9 '15 at 23:24
7

To answer your second question, the following line will change the comment text to a Gray color:

Set-PSReadlineOption -TokenKind Comment -ForegroundColor Gray

You probably will want to execute this when PowerShell is launched, if so, then add this to your Microsoft.PowerShell_profile.ps1 file.

And to answer your first question for a color scheme, you can add several lines changing the TokenKind value to any of the following members from TokenClassification enum: None, Comment, Keyword, String, Operator, Variable, Command, Parameter, Type, Number and Member. Also change the -ForgroundColor and -BackgroundColor values with any members of ConsoleColor.

There are color scheme projects available such as posh-monokai.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy