Created
January 13, 2018 19:47
-
-
Save bombsimon/c4af79a8281dca174ae2ef057715042b to your computer and use it in GitHub Desktop.
Script to check terminal color support
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
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
foreach my $red ( 0..5 ) { | |
foreach my $green ( 0..5 ) { | |
foreach my $blue ( 0..5 ) { | |
printf( | |
"\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", | |
16 + ( $red * 36 ) + ( $green * 6 ) + $blue, | |
$red ? ( $red * 40 + 55 ) : 0, | |
$green ? ( $green * 40 + 55 ) : 0, | |
$blue ? ( $blue * 40 + 55 ) : 0, | |
); | |
} | |
} | |
} | |
foreach my $gray ( 0..5 ) { | |
my $level = ( $gray * 10 ) + 8; | |
printf( | |
"\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", | |
232 + $gray, $level, $level, $level | |
) | |
} | |
print "System colors\n"; | |
print "\x1b[48;5;${_}m " for ( 0..7 ); | |
print "\x1b[0m\n"; | |
print "\x1b[48;5;${_}m " for ( 8..15 ); | |
print "\x1b[0m\n\n"; | |
print "Color cube, 6x6x6:\n"; | |
foreach my $green ( 0..5 ) { | |
foreach my $red ( 0..5 ) { | |
foreach my $blue ( 0..5 ) { | |
my $color = 16 + ( $red * 36 ) + ( $green * 6 ) + $blue; | |
print "\x1b[48;5;${color}m "; | |
} | |
print "\x1b[0m "; | |
} | |
print "\n"; | |
} | |
print "\nGrayscale ramp:\n"; | |
print "\x1b[48;5;${_}m " for ( 232..255 ); | |
print "\x1b[0m\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment