Skip to content

Instantly share code, notes, and snippets.

@B4Art
Forked from timabell/ps-colours.ps1
Last active December 14, 2020 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save B4Art/9456fbb2490b3e5c3a9d6dd24f32a665 to your computer and use it in GitHub Desktop.
Save B4Art/9456fbb2490b3e5c3a9d6dd24f32a665 to your computer and use it in GitHub Desktop.
output all the colour combinations for text/background in powershell
# output all the colour combinations for text/background
# http://stackoverflow.com/a/41954792/10245
$colors = [enum]::GetValues([System.ConsoleColor]) |
Select-Object @{N='ColorObject';E={$_}},
@{N='ColorName'; E={
If ($_.ToString().substring(0,3) -eq 'Dar' ){
$_.ToString().Substring(4) + 'DARK'
} else {
$_.ToString()
}
}
} |
Sort-Object Colorname
Foreach ($bgcolor in $colors.ColorObject){
Foreach ($fgcolor in $colors.ColorObject) { Write-Host "$fgcolor|" -ForegroundColor $fgcolor -BackgroundColor $bgcolor -NoNewLine }
Write-Host " on $bgcolor"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment