Last active
November 25, 2023 16:23
-
-
Save k-takata/2d4f562bacf8bae6691973a540970117 to your computer and use it in GitHub Desktop.
Testing ANSI color sequence on Windows 10 and other terminal emulators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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![0m | |
set str= | |
for /l %%c in (8,1,15) do ( | |
set str=!str![48;5;%%cm | |
) | |
echo !str![0m | |
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![m | |
) | |
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![0m | |
set str= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo [0;30mDark Black [1;30mLight Black[m | |
echo [0;31mDark Red [1;31mLight Red[m | |
echo [0;32mDark Green [1;32mLight Green[m | |
echo [0;33mDark Yellow [1;33mLight Yellow[m | |
echo [0;34mDark Blue [1;34mLight Blue[m | |
echo [0;35mDark Magenta [1;35mLight Magenta[m | |
echo [0;36mDark Cyan [1;36mLight Cyan[m | |
echo [0;37mDark While [1;37mLight While[m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "[0;30mDark Black [1;30mLight Black[m" | |
echo "[0;31mDark Red [1;31mLight Red[m" | |
echo "[0;32mDark Green [1;32mLight Green[m" | |
echo "[0;33mDark Yellow [1;33mLight Yellow[m" | |
echo "[0;34mDark Blue [1;34mLight Blue[m" | |
echo "[0;35mDark Magenta [1;35mLight Magenta[m" | |
echo "[0;36mDark Cyan [1;36mLight Cyan[m" | |
echo "[0;37mDark While [1;37mLight While[m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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![m | |
set str= | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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[m" | |
str= | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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![m | |
set str= | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "[m" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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![m | |
set str= | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "[m" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On mintty: