Powershell连字符参数颜色

Mul*_*enb 6 powershell colors

我想-a, --All在Powershell中更改参数的颜色.我已经像这样更改了我在Powershell中的字符串和命令颜色.

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

我找不到如何更改连字符参数的颜色.

它在Set-PSReadlineOption其他地方还是其他地方?

Mat*_*sen 8

您正在寻找Parameter令牌类型:

Set-PSReadlineOption -TokenKind Parameter -ForegroundColor Red
Run Code Online (Sandbox Code Playgroud)

上面的颜色参数标记(如-a)红色,但不是前缀为--(像--All)的裸字符串标记,因为它们在技术上不被解析器视为参数标记.

  • 更新的版本应该是`Set-PSReadLineOption -Colors @{Parameter = "Red"}`。新参数是一个分号分隔的颜色哈希表。 (3认同)

Mah*_*zad 6

您正在寻找的是这样的:

Set-PSReadLineOption -Colors @{"Parameter"="#ff81f7"}
Run Code Online (Sandbox Code Playgroud)