PSReadLine in PowerShell has syntax coloring, but how do you specify the colors?

  • 2
    Does anyone know why the default colors are so unreadable?
    – Lee Meador
    Commented Mar 18, 2021 at 17:55

2 Answers 2


There are a couple different ways. You can do this:

Set-PSReadlineOption -TokenKind Comment -ForegroundColor Green


$options = Get-PSReadlineOption
$options.CommentForegroundColor = Green

The possible colors are from the .NET ConsoleColor Enumeration. The actual RGB color values can be changed in the console properties dialog.

To see the current color settings, execute Get-PSReadlineOption by itself.

  • Great. Thanks. Do you know if there's any way to specify numeric RGB colors?
    – dangph
    Commented Nov 16, 2013 at 13:24
  • Not with PSReadline. There are only 16 possible colors available in the console. The RGB values are stored in the registry and typically changed in the Properties dialog of the console. ConsoleColor (a .Net enum) is really just an index into one of those 16 possible colors - so the name doesn't matter - if you change the right entry, it will just read the registry for that slot. Commented Nov 16, 2013 at 17:45
  • Hello, I can't find a way to set those colors in my profile file. It seems Get-PSReadlineOption is not defined and return nothing when executed from the profile file. Once the shell is loaded, there's no problem however. I tried adding an implicit Import-Module PSReadline before those lines but nothing do. Commented May 14, 2016 at 9:29
  • @JasonShirk The colors are set for the current instance of powershell. If I close and start it again the changes disappear. How can I make the changes stick?
    – krv
    Commented Jul 28, 2018 at 14:08
  • 1
    @krv - Add the settings to your profile. Commented Jul 28, 2018 at 14:23

While the methods that Jason Shirk describes still work on my Mac that has PowerShell Core version 6.0.1, as documented here, they no longer work on my Linux machine, which is on version 6.1.0.

It seems that they completely changed the interface of this cmdlet: PowerShell 6 Set-PSReadlineOption.

Now, you can supply a hash table of colors as the value to the -Colors parameter. The good thing is that you now have many more color options.

From the examples:

$colors = @{
  # ConsoleColor enum has all the old colors
  "Error" = [ConsoleColor]::DarkRed

  # A mustardy 24 bit color escape sequence
  "String" = "$([char]0x1b)[38;5;100m"

  # A light slate blue RGB value
  "Command" = "#8470FF"

Set-PSReadLineOption -Colors $colors
  • And how do you specifiy the missing color. I don't know whether foreground or background is missing but one color is not enough.
    – Lee Meador
    Commented Mar 18, 2021 at 17:40
  • @LeeMeador, could you be more specific about your issue? What is a missing color? Are you able to run my example? FWIW, I am able to run it in PowerShell 7.1.1 Commented Mar 19, 2021 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .