-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
command-line-token-color-mapping.ps1
54 lines (52 loc) · 2.76 KB
/
command-line-token-color-mapping.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# NOTE: This script is used to set syntax highlighting colors
# of the PSReadline module, and affect the colors of command line
# (only command line tokens, not prompt). It"s an enhancement,
# not decisive factor to theming. The color of tokens is determined by
# what theme you use. If you use solorized_dark, this script will automatically
# use solorized_dark mapping colours to improve the colors of command line,
# make them easier to be recognized and looks better.
#
# Since we use base16 for building themes, we follow base16's styling
# guidelines(https://github.com/chriskempson/base16/blob/master/styling.md)
# to configure token colours, for example:
# Keyword -> base0E
# String -> base0B
#
# To use this script, simply import the .ps1 script, or just
# copy below code into you your PowerShell profile. You have to install
# PSReadline module before you do it. If you are on Windows 10,
# PSReadLine is already installed. More information:
# https://github.com/lzybkr/PSReadLine#installation
if (Get-Module -ListAvailable -Name "PSReadline") {
# PSReadLine 1
if ((Get-Module -ListAvailable -Name "PSReadline").Version.Major -eq 1) {
# Reset
Set-PSReadlineOption -ResetTokenColors
$options = Get-PSReadlineOption
# Token Foreground # base16 colors
$options.CommandForegroundColor = "DarkBlue" # base0D
$options.CommentForegroundColor = "Yellow" # base03
$options.KeywordForegroundColor = "DarkMagenta" # base0E
$options.MemberForegroundColor = "DarkBlue" # base0D
$options.NumberForegroundColor = "Red" # base09
$options.OperatorForegroundColor = "DarkCyan" # base0C
$options.ParameterForegroundColor = "Red" # base09
$options.StringForegroundColor = "DarkGreen" # base0B
$options.TypeForegroundColor = "DarkYellow" # base0A
$options.VariableForegroundColor = "DarkRed" # base08
} else {
# Token Foreground # base16 colors
Set-PSReadLineOption -Colors @{
"Command" = [ConsoleColor]::DarkBlue # base0D
"Comment" = [ConsoleColor]::Yellow # base03
"Keyword" = [ConsoleColor]::DarkMagenta # base0E
"Member" = [ConsoleColor]::DarkBlue # base0D
"Number" = [ConsoleColor]::Red # base09
"Operator" = [ConsoleColor]::DarkCyan # base0C
"Parameter" = [ConsoleColor]::Red # base09
"String" = [ConsoleColor]::DarkGreen # base0B
"Type" = [ConsoleColor]::DarkYellow # base0A
"Variable" = [ConsoleColor]::DarkRed # base08
}
}
}