powershell_字体颜色高亮配置(by official doc(PSReadLineModule))/多种颜色值参考表
文章目录
refenrence link
Set-PSReadLineOption (PSReadLine) - PowerShell | Microsoft Docs
PSReadLineOption可以配置的选项包括:
Set-PSReadLineOption
[-EditMode <EditMode>]
[-ContinuationPrompt <String>]
[-HistoryNoDuplicates]
[-AddToHistoryHandler <System.Func`2[System.String,System.Object]>]
[-CommandValidationHandler <System.Action`1[System.Management.Automation.Language.CommandAst]>]
[-HistorySearchCursorMovesToEnd]
[-MaximumHistoryCount <Int32>]
[-MaximumKillRingCount <Int32>]
[-ShowToolTips]
[-ExtraPromptLineCount <Int32>]
[-DingTone <Int32>]
[-DingDuration <Int32>]
[-BellStyle <BellStyle>]
[-CompletionQueryItems <Int32>]
[-WordDelimiters <String>]
[-HistorySearchCaseSensitive]
[-HistorySaveStyle <HistorySaveStyle>]
[-HistorySavePath <String>]
[-AnsiEscapeTimeout <Int32>]
[-PromptText <String[]>]
[-ViModeIndicator <ViModeStyle>]
[-ViModeChangeHandler <ScriptBlock>]
[-PredictionSource <PredictionSource>]
[-PredictionViewStyle <PredictionViewStyle>]
[-Colors <Hashtable>]
[<CommonParameters>]
Color
如果要配置颜色,则是选择-Colors
选项
其值是<Hashtable>
Set foreground and background colors
Set-PSReadLineOption -Colors @{ "Comment"="`e[32;47m" }
# You can choose to set only a foreground text color. For example, a bright green foreground text color for the Comment token: ``"Comment"="`e[92m"``.
Set-PSReadLineOption -Colors @{
Command = 'Magenta'
Number = 'DarkGray'
Member = 'DarkGray'
Operator = 'DarkGray'
Type = 'DarkGray'
Variable = 'DarkGreen'
Parameter = 'DarkGreen'
ContinuationPrompt = 'DarkGray'
Default = 'DarkGray'
}
Set color values for multiple types
Set-PSReadLineOption -Colors @{
# Use a ConsoleColor enum
"Error" = [ConsoleColor]::DarkRed
# 24 bit color escape sequence
"String" = "$([char]0x1b)[38;5;100m"
# RGB value
"Command" = "#8181f7"
}
The valid keys include:
这些key介绍了那些类型的文字可以配置高亮
(一般配置selection/inlinePrediction)即可
- ContinuationPrompt : The color of the continuation prompt.
- Emphasis : The emphasis color. For example, the matching text when searching history.
- Error : The error color. For example, in the prompt.
- Selection : The color to highlight the menu selection or selected text.
- Default : The default token color.
- Comment : The comment token color.
- Keyword : The keyword token color.
- String : The string token color.
- Operator : The operator token color.
- Variable : The variable token color.
- Command : The command token color.
-
- Parameter : The parameter token color.
- Type : The type token color.
- Number : The number token color.
- Member : The member name token color.
- InlinePrediction : The color for the inline view of the predictive suggestion.
颜色值表达推荐
powershell支持多种颜色表示方式,而使用RGB比较方便(单词也不错)
颜色表参考
配置效果
以补全选中(selection
)为例:
另外以行内预测补全(inlinePrediction
)为例