neilpa/cmd-colors-solarized

Set ColorDefaults not working with latest powershell (v6)

Closed this issue · 2 comments

I was trying to run the Set-SolarizedDarkColorDefaults.ps1, but it gave me an error:

The property 'CommandForegroundColor' cannot be found on this object. Verify that the property exists and can be set.

That is because Get-PSReadlineOption returns a different object now and colors are set in a different manner:

[...]
CommandColor                           : "$([char]0x1b)[93m"
CommentColor                           : "$([char]0x1b)[32m"
ContinuationPromptColor                : "$([char]0x1b)[34m"
DefaultTokenColor                      : "$([char]0x1b)[34m"
EmphasisColor                          : "$([char]0x1b)[96m"
ErrorColor                             : "$([char]0x1b)[91m"
KeywordColor                           : "$([char]0x1b)[92m"
MemberColor                            : "$([char]0x1b)[97m"
NumberColor                            : "$([char]0x1b)[97m"
OperatorColor                          : "$([char]0x1b)[90m"
ParameterColor                         : "$([char]0x1b)[90m"
SelectionColor                         : "$([char]0x1b)[30;44m"
StringColor                            : "$([char]0x1b)[36m"
TypeColor                              : "$([char]0x1b)[37m"
VariableColor                          : "$([char]0x1b)[92m"

The new way to set colors is described here: https://docs.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption?view=powershell-6#examples

I fixed this in the existing file, but there seems to be two new color options, comment and selection.

Set-PSReadLineOption -Colors @{
        "Command" = [ConsoleColor]::Yellow
        #"Comment" = [ConsoleColor]::
        "ContinuationPrompt" = [ConsoleColor]::DarkBlue
        "DefaultToken" = [ConsoleColor]::DarkBlue
        "Emphasis" = [ConsoleColor]::Cyan
        "Error" = [ConsoleColor]::Red
        "Keyword" = [ConsoleColor]::Green
        "Member" = [ConsoleColor]::DarkCyan
        "Number" = [ConsoleColor]::DarkCyan
        "Operator" = [ConsoleColor]::DarkGreen
        "Parameter" = [ConsoleColor]::DarkGreen
        #"Selection" = [ConsoleColor]::
        "String" = [ConsoleColor]::Blue
        "Type" = [ConsoleColor]::DarkYellow
        "Variable" = [ConsoleColor]::Green
       }

Seems someone already fixed it with this pull request #41.