forked from neilpa/cmd-colors-solarized
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathOut-Colors.ps1
69 lines (60 loc) · 2.47 KB
/
Out-Colors.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#Requires -Version 3
# Map the Solarized colors to their ColorTable pairings
$SolarizedPallet = [ordered]@{
'base03' = 'Black'
'base02' = 'DarkGray'
'base01' = 'DarkGreen'
'base00' = 'DarkYellow'
'base0' = 'DarkBlue'
'base1' = 'DarkCyan'
'base2' = 'Gray'
'base3' = 'White'
'yellow' = 'Yellow'
'orange' = 'DarkRed'
'red' = 'Red'
'magenta' = 'Magenta'
'violet' = 'DarkMagenta'
'blue' = 'Blue'
'cyan' = 'Cyan'
'green' = 'Green'
}
$PalletSolarized = @{} # Will be used to invert the mapping
Write-Host
# Try and use the default background color to identify the installed theme
$BackgroundColor = switch ($HOST.UI.RawUI.BackgroundColor.ToString()) {
'DarkMagenta' {'DarkMagenta'} # None
'White' {'Gray'} # Light
'Black' {'DarkGray'} # Dark
}
# Draw table of Solarized mappings
Write-Host ("{0,-15} | {1,-15} | {2,-15}" -f "Solarized", "Light", "Dark") -BackgroundColor $BackgroundColor
$SolarizedPallet.keys | `
ForEach-Object {
Write-Host ("{0,-15}" -f $_) -BackgroundColor $BackgroundColor -NoNewline
Write-Host (" | " -f $_) -BackgroundColor $BackgroundColor -NoNewline
Write-Host ("{0,-15}" -f $SolarizedPallet[$_]) -NoNewline `
-ForegroundColor $SolarizedPallet[$_] `
-BackgroundColor 'White'
Write-Host (" | " -f $_) -BackgroundColor $BackgroundColor -NoNewline
Write-Host ("{0,-15}" -f $SolarizedPallet[$_]) `
-ForegroundColor $SolarizedPallet[$_] `
-BackgroundColor 'Black'
$PalletSolarized.Add($SolarizedPallet[$_], $_) # Create the inverted map
}
Write-Host
$Colors = [Enum]::GetValues( [System.ConsoleColor] )
# Draw table of ColorTable mappings
Write-Host ("{0,-15} | {1,-15} | {2,-15}" -f "Color Table", "Light", "Dark") -BackgroundColor $BackgroundColor
$Colors | `
ForEach-Object {$i=0}{
Write-Host ("{0,-11} [{1:X}]" -f $_.ToString(), $i++) -BackgroundColor $BackgroundColor -NoNewline
Write-Host (" | " -f $_.ToString()) -BackgroundColor $BackgroundColor -NoNewline
Write-Host ("{0,-15}" -f $PalletSolarized[$_.ToString()]) -NoNewline `
-ForegroundColor $_.ToString() `
-BackgroundColor 'White'
Write-Host (" | " -f $_.ToString()) -BackgroundColor $BackgroundColor -NoNewline
Write-Host ("{0,-15}" -f $PalletSolarized[$_.ToString()]) `
-ForegroundColor $_.ToString() `
-BackgroundColor 'Black'
}
Write-Host