Created
June 1, 2011 13:39
-
-
Save ytaniike/1002305 to your computer and use it in GitHub Desktop.
Convenient for setting up tmux and other terminal software.
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/perl | |
# displays the 256 colors specified in tmux's "colourNN" way. | |
# June, 1st 2011 by Yasunori Taniike (@ytaniike). | |
use strict; | |
use warnings; | |
my $prefix_bl = "\x1b[38;5;0;48;5;"; | |
my $prefix_wl = "\x1b[38;5;15;48;5;"; | |
my $suffix = "\x1b[0m"; | |
sub _color_part { | |
my $color = shift; | |
return sprintf("m C%03d ", $color); | |
} | |
# for colors0 to colors7 (also known as "system colors": black, red, green, yellow, | |
# blue, magenta, cyan, white) | |
print "System colors: 8 colors x 2 rows:\n"; | |
foreach my $color (0..7) { | |
print "$prefix_wl$color" . _color_part($color); | |
} | |
print "$suffix\n"; | |
foreach my $color (8..15) { | |
print "$prefix_bl$color" . _color_part($color); | |
} | |
print "$suffix\n\n"; | |
print "colour16 to colour231:\n"; | |
my $index_offset = 15; | |
my $prefix = $prefix_wl; | |
foreach my $color (16..231) { | |
$prefix = $prefix_bl if ($color > 123); | |
print "$prefix$color" . _color_part($color); | |
print "$suffix\n" | |
if (($color - $index_offset) % (2*6) == 0); | |
} | |
print "\n"; | |
# grayscale | |
print "colour232 to colour255: Gray scale\n"; | |
$prefix = $prefix_wl; | |
foreach my $color (232..255) { | |
$prefix = $prefix_bl if ($color > 243); | |
print "$prefix$color" . _color_part($color); | |
print "$suffix\n" | |
if (($color - $index_offset) % (2*6) == 0); | |
} | |
exit (0); |
Hi, Magnus! Thank you for the info.
I tried to check c256 out.
Downloaded the source from Github.
perl Makefile.PL
make
sudo make install
When I run it, I've got errors.
Can't locate Term/ExtendedColor.pm in @inc (@inc contains: /etc/perl
/usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10
/usr/local/lib/site_perl .) at /usr/local/bin/c256 line 13.
BEGIN failed--compilation aborted at /usr/local/bin/c256 line 13.
I'm gonna check it out tomorrow. It's 3am here, I've got sleep.
Good night!
2011/6/2 trapd00r
[email protected]:
##
Yasunori Taniike ([email protected])
@ytaniike on Twitter
Right; you need my two color modules (also on the cpan); to install, just:
cpan Term::ExtendedColor Term::ExtendedColor::Xresources
this is so you can see the actual color values as well as their indexes (in color).
Right; you need my two color modules (also on the cpan); to install, just:
cpan Term::ExtendedColor Term::ExtendedColor::Xresources
I've already them instted and checked em out.
With --hex option, c256 --hex produced no results.
I've got stop the run by sending SIGTERM to c256.
my script is planed to show colour number in tmux, your tools seems to
designed to be more technically point of view (mine is just
practical).
In anyway, Thanks you for the information.
##
Yasunori Taniike
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you know which 'colour' numbers, when you've got to or tried to setup tmux?
I've got a lost with a perl script that only displays colors, and wrote this script.
Enjoy :)