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: 2729

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.03 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 foreground (background color in parentheses)\\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 8; do 21 echo -e "\\033[${h};3${f}\\c" 22 if [ $b -lt 8 ]; then 23 echo -e ";4${b}m\\c" 24 else 25 echo -e "m\\c" 26 fi 27 case $f in 28 0) echo -e " BLACK \\c" ;; 29 1) echo -e " RED \\c" ;; 30 2) echo -e " GREEN \\c" ;; 31 3) echo -e " YELLOW\\c" ;; 32 4) echo -e " BLUE \\c" ;; 33 5) echo -e "MAGENTA\\c" ;; 34 6) echo -e " CYAN \\c" ;; 35 7) echo -e " WHITE \\c" ;; 36 esac 37 case $b in 38 8) echo -e "\\033[m" ;; 39 *) echo -e " \\033[m \\c" ;; 40 esac 41 done 42 done 43 echo -e "\\033[${h}m\\c" 44 for b in 0 1 2 3 4 5 6 7 8; do 45 case $b in 46 0) echo -e "(black) \\c" ;; 47 1) echo -e " (red) \\c" ;; 48 2) echo -e "(green) \\c" ;; 49 3) echo -e "(yellow) \\c" ;; 50 4) echo -e " (blue) \\c" ;; 51 5) echo -e "(magenta)\\c" ;; 52 6) echo -e " (cyan) \\c" ;; 53 7) echo -e "(white) \\c" ;; 54 8) echo -e " (none)\\c" ;; 55 esac 56 done 57 echo -e "\\033[m\\n" 58 done 59

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS