找不到与参数名称“ TokenKind”匹配的参数

Z-Y*_*Y.L 4 powershell psreadline

根据此博客,我已经美化了Powershell ,但是OperatorParameter如下所示为灰色:

在此处输入图片说明 在此处输入图片说明

所以我通过Set-PSReadlineOption以下方式更改它们的颜色:

Set-PSReadlineOption -TokenKind Operator -ForegroundColor Yellow
Run Code Online (Sandbox Code Playgroud)

但出现以下错误:

Set-PSReadLineOption:找不到与参数名称“ TokenKind”匹配的参数

???? ?:1 ??:22

  • Set-PSReadlineOption -TokenKind运算符-ForegroundColor黄色
    • CategoryInfo:InvalidArgument:(:) [Set-PSReadLineOption]?ParameterBindingException
    • FullyQualifiedErrorId:NamedParameterNotFound,Microsoft.PowerShell.SetPSReadLineOption

但是显示的帮助文件Set-PSReadlineOption显示它具有一个TokenKind参数,Operator而该参数又可以作为其参数。

我很困惑为什么会发生此错误。

我的powershell版本是

在此处输入图片说明

感谢您的任何建议!

use*_*429 6

他们进行了PSReadline V2的重大更改,请在此处阅读:https : //github.com/lzybkr/PSReadLine/issues/738

所以代替

Set-PSReadlineOption -TokenKind String -ForegroundColor Magenta
Set-PSReadlineOption -TokenKind Variable -ForegroundColor Cyan
Run Code Online (Sandbox Code Playgroud)

你会做类似的事情

$colors = @{}
$colors['String'] = [System.ConsoleColor]::Magenta
$colors['Variable'] = [System.ConsoleColor]::Cyan
Set-PSReadLineOption -Colors $colors
Run Code Online (Sandbox Code Playgroud)

我认为也有一种在哈希表中指定前景色/背景色的方法,但尚未弄清楚。

此处阅读Set-PSReadLineOption文档。

  • 感谢您的信息!阅读了第738期后,我发现`Set-PSReadLineOption -Colors @ {Operator =“ Yellow”; 参数=“黄色”;Command =“ Blue”; String =“ DarkYellow”}`符合我的预期。再次感谢! (3认同)