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
)为例
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2023-08-25 java_童年生活二三事