I'm not going to write down all ~7million (which you can apparently use now if your terminal can display them), but here are the main ones, all named for you
I've included other things like "bold
", underline
, and negative
.
Just call them like this (fg
for foreground
, bg
for background
, and bf
/bg
for "bright" foreground/background. default
to reset and there's fg.default
+ bg.default
too for resetting those individually)
$style.fg.green + 'Im green!'
'I feel a little ',$style.bg.black,' moody' -join ''
"Math is pretty $($style.negative)$(191 * 7)$($style.default) too"

Those 24-bit colours a aluded to? $style.bg.rgb -f 120,32,230
. Maybe you're running pwsh on linux or come from a 'nix background? $style.fg.x -f 30
xterm colours will make you feel at home.
#console colours (VT escape sequences)
$style=@(
0, 'default', 'bold',
4, 'underline',
24, 'nounderline',
7, 'negative',
27, 'positive',
'_fg',
30, 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white',
39, 'default',
'_bg',
'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white',
49, 'default',
'_bf', 90, 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white',
'_bb', 100, 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
) `
| &{
Begin {
$sequence="$([char]27)[{0}m"
$style=@{
fg=@{
rgb=$sequence -f '38;2;{0};{1};{2}'
x=$sequence -f '38;5;{0}'
};
bg=@{
rgb=$sequence -f '48;2;{0};{1};{2}'
x=$sequence -f '48;5;{0}'
};
bf=@{};
bb=@{};
}
$current=$style
$index=$null
}
Process {
Switch -regex ($_) {
'\d' { $index=$_ }
'^_' { $current=$style[$_ -replace '^.',''] }
Default {
$current[$_]=$sequence -f $index++
#comment me out
"$($current[$_])$($_)`t" | Out-Host
}
}
}
End {
$style
#more demonstrations
@(($style.bg.rgb -f 120,32,230), ($style.fg.x -f 30), 'hello', $style.default) -join '' | Out-Host
}
}
Apparently you can set hyperlinks and truncated text too!
https://github.com/PowerShell/PowerShell/issues/7744