Try all colors in xterm with script before setting the color

2011-03-18 2 min read bash Fedora Learning Linux

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.

  <td>
    <div class="text codecolorer">
      #!/bin/bash -<br /> #===============================================================================<br /> #<br /> #          FILE:  xterm_colors-test.sh<br /> #<br /> #         USAGE:  ./xterm_colors-test.sh<br /> #<br /> #   DESCRIPTION:  Test all the colors for xterm bg<br /> #<br /> #       OPTIONS:  ---<br /> #  REQUIREMENTS:  ---<br /> #          BUGS:  ---<br /> #         NOTES:  ---<br /> #        AUTHOR:   Amit Agarwal (amit.agarwal@amit-agarwal.co.in), aka<br /> #       COMPANY:  Individual<br /> #       VERSION:  1.0<br /> #       CREATED:  02/18/2011 01:02:51 PM IST<br /> #      REVISION:  1.0<br /> #===============================================================================<br /> <br /> cat /usr/share/X11/rgb.txt |sed 's/\([0-9]\{1,3\}[ \t]*\)\{3\}//'|sed 's/^ *//' >~/rgb.txt<br /> while read line<br /> do<br /> bg=$(echo $line)<br /> echo $line<br /> echo "Trying $bg color"<br /> xterm -bg "$bg"&<br /> sleep 5<br /> kill -9 $!<br /> done < ~/rgb.txt
    </div>
  </td>
</tr>
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

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:

  <td>
    <div class="text codecolorer">
      xterm -bg "$bg" -e "ls && sleep 5"
    </div>
  </td>
</tr>
1

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
comments powered by Disqus