更改 powershell 命令颜色

rw0*_*026 8 powershell intellij-idea

如何在powershell中更改命令颜色?目前它是黄色的,当我使用嵌套在 Intellij 中的 powershell 时,我无法读取白色背景上的黄色命令。

powershell 命令颜色

rw0*_*026 7

关于@LotPings 的回答,我解决了我的问题。powershell 中的以下命令将命令颜色从黄色更改为绿色:

Set-PSReadLineOption -colors @{ Command = "Green"}
Run Code Online (Sandbox Code Playgroud)


Ste*_*fan 6

您还可以在终端设置中设置环境变量:

IntelliJ 终端设置

然后编辑你的 powershell 配置文件并添加如下内容:

if ($env:CommandColor) {
    Set-PSReadLineOption -colors @{ Command = $env:CommandColor}
}
Run Code Online (Sandbox Code Playgroud)


小智 5

请参阅 cmdlet Get-PSReadlineOptionSet-PSReadlineOption

您可能想要更改:

Set-PSReadlineOption -Tokenkind Command -BackgroundColor Black
Run Code Online (Sandbox Code Playgroud)

或查看当前设置:

> Get-PSReadlineOption

EditMode                               : Windows
ContinuationPrompt                     : >>
ContinuationPromptForegroundColor      : DarkYellow
ContinuationPromptBackgroundColor      : DarkMagenta
ExtraPromptLineCount                   : 0
AddToHistoryHandler                    :
CommandValidationHandler               :
CommandsToValidateScriptBlockArguments : {ForEach-Object, %, Invoke-Command, icm...}
HistoryNoDuplicates                    : False
MaximumHistoryCount                    : 4096
MaximumKillRingCount                   : 10
HistorySearchCursorMovesToEnd          : False
ShowToolTips                           : False
DingTone                               : 1221
CompletionQueryItems                   : 100
WordDelimiters                         : ;:,.[]{}()/\|^&*-=+'"–—?
DingDuration                           : 50
BellStyle                              : Audible
HistorySearchCaseSensitive             : False
ViModeIndicator                        : None
HistorySavePath                        : C:\Users\LotPings\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\Cons
                                         oleHost_history.txt
HistorySaveStyle                       : SaveIncrementally
DefaultTokenForegroundColor            : DarkYellow
CommentForegroundColor                 : DarkGreen
KeywordForegroundColor                 : Green
StringForegroundColor                  : DarkCyan
OperatorForegroundColor                : DarkGray
VariableForegroundColor                : Green
CommandForegroundColor                 : Yellow
ParameterForegroundColor               : DarkGray
TypeForegroundColor                    : Gray
NumberForegroundColor                  : White
MemberForegroundColor                  : White
DefaultTokenBackgroundColor            : DarkMagenta
CommentBackgroundColor                 : DarkMagenta
KeywordBackgroundColor                 : DarkMagenta
StringBackgroundColor                  : DarkMagenta
OperatorBackgroundColor                : DarkMagenta
VariableBackgroundColor                : DarkMagenta
CommandBackgroundColor                 : DarkMagenta
ParameterBackgroundColor               : DarkMagenta
TypeBackgroundColor                    : DarkMagenta
NumberBackgroundColor                  : DarkMagenta
MemberBackgroundColor                  : DarkMagenta
EmphasisForegroundColor                : Cyan
EmphasisBackgroundColor                : DarkMagenta
ErrorForegroundColor                   : Red
ErrorBackgroundColor                   : DarkMagenta
Run Code Online (Sandbox Code Playgroud)

  • 我无法使用“-Tokenkind”选项。 (3认同)

Ant*_*ntu 0

访问此链接了解如何更改 PowerShell 命令颜色。

另外,您可以使用Ohmyz 自定义您的 PowerShell,他们还有一些很棒的插件主题