You're here: Snippet Directory » UNIX Admin (199)
Language:

ANSI terminal color chart generator

Language: English
Programming Language: Unix Shell
Published by: ijabbott [not registered]
Last Update: 5/15/2006
Views: 2007

License: BSD License

Description

A simple Bourne shell script to generate an ANSI terminal color chart - background color, foreground color, normal and high intensity. Output fits nicely on an 80x24 terminal.

Code

1 #!/bin/sh 2 # 3 # colors v1.01 4 # 5 # A simple shell script to output an ANSI terminal color chart. 6 # It may be useful when trying to customize your ANSI terminal 7 # color scheme! 8 # 9 # Written and placed in the public domain by Ian Abbott <ian@abbott.org> 10 # 11 12 for h in 0 1; do 13 echo -e "\\033[0;${h}m\\c" 14 case $h in 15 0) echo -e "Normal\\c" ;; 16 1) echo -e "High\\c" ;; 17 esac 18 echo -e " intensity\\033[m" 19 for f in 0 1 2 3 4 5 6 7; do 20 for b in 0 1 2 3 4 5 6 7; do 21 echo -e "\\033[${h};3${f};4${b}m\\c" 22 case $f in 23 0) echo -e " BLACK \\c" ;; 24 1) echo -e " RED \\c" ;; 25 2) echo -e " GREEN \\c" ;; 26 3) echo -e " YELLOW \\c" ;; 27 4) echo -e " BLUE \\c" ;; 28 5) echo -e " MAGENTA \\c" ;; 29 6) echo -e " CYAN \\c" ;; 30 7) echo -e " WHITE \\c" ;; 31 esac 32 case $b in 33 7) echo -e "\\033[m" ;; 34 *) echo -e "\\033[m \\c" ;; 35 esac 36 done 37 done 38 for b in 0 1 2 3 4 5 6 7; do 39 case $b in 40 0) echo -e " (black) \\c" ;; 41 1) echo -e " (red) \\c" ;; 42 2) echo -e " (green) \\c" ;; 43 3) echo -e "(yellow) \\c" ;; 44 4) echo -e " (blue) \\c" ;; 45 5) echo -e "(magenta) \\c" ;; 46 6) echo -e " (cyan) \\c" ;; 47 7) echo -e " (white) \\n" ;; 48 esac 49 done 50 done 51

One comment

1

Nice!

Friday, November 24, 2006 1:42:37 PM from Rainer Jung

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS