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 multiple options

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)为例
在这里插入图片描述

posted @   xuchaoxin1375  阅读(27)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2023-08-25 java_童年生活二三事
点击右上角即可分享
微信分享提示