Skip to content

Instantly share code, notes, and snippets.

@grokk-it
Last active October 24, 2020 07:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grokk-it/8d49e6e2445a93276275a9d87c45b81f to your computer and use it in GitHub Desktop.
Save grokk-it/8d49e6e2445a93276275a9d87c45b81f to your computer and use it in GitHub Desktop.
PowerShell ANSI 256-color chart
# 256-Color Foreground & Background Charts
$esc=$([char]27)
echo "`n$esc[1;4m256-Color Foreground & Background Charts$esc[0m"
foreach ($fgbg in 38,48) { # foreground/background switch
foreach ($color in 0..255) { # color range
#Display the colors
$field = "$color".PadLeft(4) # pad the chart boxes with spaces
Write-Host -NoNewLine "$esc[$fgbg;5;${color}m$field $esc[0m"
#Display 6 colors per line
if ( (($color+1)%6) -eq 4 ) { echo "`r" }
}
echo `n
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment