Skip to content

Instantly share code, notes, and snippets.

@k-takata
Last active November 25, 2023 16:23
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save k-takata/2d4f562bacf8bae6691973a540970117 to your computer and use it in GitHub Desktop.
Save k-takata/2d4f562bacf8bae6691973a540970117 to your computer and use it in GitHub Desktop.
Testing ANSI color sequence on Windows 10 and other terminal emulators
@echo off
rem Based on Todd Larason's 256color2.pl.
rem Ported to Windows 10's Command Prompt.
setlocal EnableDelayedExpansion
rem display the colors
rem first the system ones:
echo System colors:
set str=
for /l %%c in (0,1,7) do (
set str=!str![48;5;%%cm
)
echo !str!
set str=
for /l %%c in (8,1,15) do (
set str=!str![48;5;%%cm
)
echo !str!
set str=
echo.
rem now the color cube
echo Color cube, 6x6x6:
for /l %%g in (0,1,5) do (
for /l %%r in (0,1,5) do (
for /l %%b in (0,1,5) do (
set /a val=16 + %%r * 36 + %%g * 6 + %%b
set str=!str![48;5;!val!m
)
set str=!str!
)
echo !str!
set str=
)
rem now the grayscale ramp
echo Grayscale ramp:
for /l %%c in (232,1,255) do (
set str=!str![48;5;%%cm
)
echo !str!
set str=
@echo off
echo Dark Black Light Black
echo Dark Red Light Red
echo Dark Green Light Green
echo Dark Yellow Light Yellow
echo Dark Blue Light Blue
echo Dark Magenta Light Magenta
echo Dark Cyan Light Cyan
echo Dark While Light While
#!/bin/sh
echo "Dark Black Light Black"
echo "Dark Red Light Red"
echo "Dark Green Light Green"
echo "Dark Yellow Light Yellow"
echo "Dark Blue Light Blue"
echo "Dark Magenta Light Magenta"
echo "Dark Cyan Light Cyan"
echo "Dark While Light While"
@echo off
setlocal EnableDelayedExpansion
set str=
for /l %%i in (0,32,255) do (
for /l %%j in (0,32,255) do (
for /l %%k in (0,32,255) do (
set str=!str![48;2;%%i;%%j;%%km
)
)
echo !str!
set str=
)
#!/bin/bash
str=
for ((i = 0; i < 256; i += 32)); do
for ((j = 0; j < 256; j += 32)); do
for ((k = 0; k < 256; k += 32)); do
str="$str[48;2;${i};${j};${k}m "
done
done
echo "$str"
str=
done
@echo off
setlocal EnableDelayedExpansion
set val=
set str=
for /l %%i in (0,1,15) do (
for /l %%j in (0,1,15) do (
set /a val=%%i * 16 + %%j
set val=00!val!
set val=!val:~-3!
set str=!str! [38;5;!val!m!val!
)
echo !str!
set str=
)
#!/bin/bash
set val=
set str=
for ((i = 0; i < 16; i++)); do
for ((j = 0; j < 16; j++)); do
val=$(($i * 16 + $j))
printf "[38;5;%dm%03d " $val $val
done
echo ""
done
@echo off
setlocal EnableDelayedExpansion
set val=
set str=
for /l %%i in (0,1,15) do (
for /l %%j in (0,1,15) do (
set /a val=%%i * 16 + %%j
set str=!str![48;5;!val!m
)
echo !str!
set str=
)
#!/bin/bash
set val=
set str=
for ((i = 0; i < 16; i++)); do
for ((j = 0; j < 16; j++)); do
val=$(($i * 16 + $j))
printf "[48;5;%dm " $val
done
echo ""
done
@k-takata
Copy link
Author

On mintty:
color-mintty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment