【发布时间】:2019-07-25 19:04:45
【问题描述】:
【问题讨论】:
【问题讨论】:
关于@LotPings 的回答,我解决了我的问题。 powershell 中的以下命令将命令颜色从黄色更改为绿色:
Set-PSReadLineOption -colors @{ Command = "Green"}
【讨论】:
查看 cmdlet Get-PSReadlineOption 和 Set-PSReadlineOption
你可能想改变:
Set-PSReadlineOption -Tokenkind Command -BackgroundColor Black
或查看当前设置:
> 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
【讨论】:
-Tokenkind 选项。
您也可以在终端设置中设置环境变量:
然后编辑您的 powershell 配置文件并添加如下内容:
if ($env:CommandColor) {
Set-PSReadLineOption -colors @{ Command = $env:CommandColor}
}
【讨论】: