Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Colours

DZone's Guide to

Colours

·
Free Resource
Display all the pretty colours in an xterm (or PuTTY session) so you can choose the combination you need...

Really helpful when you're writing a program and want to display something, or are hacking on your .dircolors or similar...


#!/usr/bin/perl
#
# JohnGH 29/12/2007
#
use warnings;
use strict;

my @range = ( 0 .. 8, 30 .. 37, 41 .. 47 , 90 .. 107);

my $count = shift;

if ( $count == 1 ) {

    for my $a ( @range ) {

        print "\e[${a}m$a\e[0m\n";

    }

}
elsif ( $count == 2 ) {

    for my $a ( @range ) {

        for my $b ( @range ) {

            print "\e[$a;${b}m$a;$b\e[0m\n";

        }

    }

} else {

    for my $a ( @range ) {

        for my $b ( @range ) {

            for my $c ( @range ) {

                print "\e[$a;$b;${c}m$a;$b;$c\e[0m\n";

            }

        }

    }

}
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}