Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Throughout the internet I have seen many people with scripts that prints out a bunch of stuff in all the colors defined in ~/.Xdefaults. However when I try to use these, I always get error: Bad Substitution. Does anyone have a working script that does the same thing?

It should end up looking something like this: enter image description here

share|improve this question
    
Maybe it's easier if you post the script you're using, and how and from where you're invocating it. –  luri Feb 20 '11 at 21:56
    
With one of the scripts that don't work, try to change the first line to #!/bin/sh (if it isn't already that) and see if it makes a difference (it should be something similar) –  Stefano Palazzo Feb 20 '11 at 22:07

4 Answers 4

up vote 16 down vote accepted

Here's my version:

#!/usr/bin/env python
import sys
terse = "-t" in sys.argv[1:] or "--terse" in sys.argv[1:]

for i in range(2 if terse else 10):
    for j in range(30, 38):
        for k in range(40, 48):
            if terse:
                print "\33[%d;%d;%dm%d;%d;%d\33[m " % (i, j, k, i, j, k),
            else:
                print ("%d;%d;%d: \33[%d;%d;%dm Hello, World! \33[m " %
                    (i, j, k, i, j, k, ))
        print 

This prints everything. If you want a nice table (that only shows style (0) and (1), normal and bold), you can use the -t or --terse argument:

The 'blink' style (5) doesn't work with gnome-terminal. ;-)


If this doesn't work for you, there's something else wrong. Please let us know once you've tested it.

share|improve this answer
    
My prompt color is defined like this: DULL=0 BRIGHT=1 FG_WHITE=37 WHITE="\[$ESC[${DULL};${FG_WHITE}m\]" Why is it, that the dull white (0;37;40) is more gray than white, and the bright white (1;37;40) is bolded? I'd like to set the terminal font to bright-white-on-black, not bolded. When I run your script, 1;37;40 looks perfectly allright after the first line: 5img.com/img13/740/24screenshot.png So, my PS1 line is in the color of the text 0;30;40; I'd like it in the color of 0;30;41. –  dep Nov 17 '11 at 10:59
    
Does anyone else find this magenta particularly ugly? It looks like mud. –  Ether Jun 13 '12 at 18:37

Here is my solution with bash only:

for x in 0 1 4 5 7 8; do for i in `seq 30 37`; do for a in `seq 40 47`; do echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "; done; echo; done; done; echo "";

Here's a picture:

image showing the output of that command in bash

share|improve this answer

You can also use the colortest Install colortest package.

  1. Install it with this command:

    sudo apt-get install colortest
    
  2. It provides several commands which you can use, depending on how many colors you want:

    colortest-16   colortest-16b  colortest-256  colortest-8
    

Example output from colortest-16b:

enter image description here

share|improve this answer

Refer http://askubuntu.com/a/396555/41013 That will print the following output with formats like BOLD ,UNDERLINE , Highlighting and colors.

Small script to display possible terminal colors

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.