Try all colors in xterm with script before setting the color

If you are looking for testing the colors on how they would look like in the xterm before you set the color then here is a small script for you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash -
#===============================================================================
#
#          FILE:  xterm_colors-test.sh
#
#         USAGE:  ./xterm_colors-test.sh
#
#   DESCRIPTION:  Test all the colors for xterm bg
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR:   Amit Agarwal (amit.agarwal@amit-agarwal.co.in), aka
#       COMPANY:  Individual
#       VERSION:  1.0
#       CREATED:  02/18/2011 01:02:51 PM IST
#      REVISION:  1.0
#===============================================================================

cat /usr/share/X11/rgb.txt |sed 's/\([0-9]\{1,3\}[ \t]*\)\{3\}//'|sed 's/^ *//' >~/rgb.txt
while read line
do
bg=$(echo $line)
echo $line
echo "Trying $bg color"
xterm -bg "$bg"&
sleep 5
kill -9 $!
done < ~/rgb.txt

This can be used in various ways but I will leave the choice to you. One option that I should probably still tell is :

Execute a command like ls to see how the settings for dircolors would look like in the terminal. To do this change the line where we are invoking xterm to the below line:

1
xterm -bg "$bg" -e "ls && sleep 5"

Do remember the sleep to some suitable time according to your needs.

Hope this helps you choose the color you want for your xterm background.

Enhanced by Zemanta

About Amit Agarwal

2 Comments on “Try all colors in xterm with script before setting the color”