Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I love colors in my console, and I wonder if there is any way to get a terminal (I guess only a software is able to do that) printing almost everything in colors. Of course there is the --color=auto things, but it works for a few commands (ls, grep...?). What I would want, is something way more colorful, that works also for commands that are not made to use colors, I don't know if it's possible.

For instance, there is MobaXTerm for Windows (something like Cygwin) which uses a lot of color. Of course it's not only a terminal, but a complete software (another layer)... maybe it's the only way to get something seriously colorized?

Any clue would be really appreciated.

share|improve this question
See Colour highlighting output based on regex in shell on StackOverflow. – manatwork Nov 21 '12 at 10:24
Thanks guys for you replies, but that's really not what I'm looking for. I would want something that does not need to change my habits. Like a terminal software that applies color to the output... – Guillaume Fenollar Nov 21 '12 at 16:04
What about a shell? Take a look at fish, the friendly interactive shell. – manatwork Nov 21 '12 at 16:24

6 Answers 6

There is a nice blog post about colorizing the terminal. Except for using built in color support in different tools it recommends grc, the Generic Colouriser. If you are on a Debian based system you can install it via

sudo apt-get install grc

You can then use give a command you want to colorize as argument to grc, e.g.

grc head /var/log/syslog

This relies on configuration in /etc/grc.conf being able to choose a proper configuration file to colorize head /var/log/syslog with. In this case it works because there are lines in /etc/grc.conf that directs grc to the correct configuration file, i.e. conf.log.

If one wants to force a particular configuration file on a particular output one can use grcat, e.g.

git diff | grcat conf.diff

which colorizes the output of git diff with the configuration file conf.diff. The configuration files I have mentioned are default ones that comes with the packages but one can obviously make own configurations.

share|improve this answer

First, concerning colors in general, this script might interest you. It works fine in the console (in a terminal, the tab width doesn't get set correctly).


setterm -regtabs 4
Color_names="bla red gre yel blu mag cya whi"

tput setaf 4
tput setab 7
echo -n "            normal             "
tput sgr0

echo -n " "

tput setaf 7
tput setab 4   
echo "            bright             "

tput sgr0
for cmd in sgr0 bold
    tput $cmd
    for m in 0 1 2 3 4 5 6 7
        tput setaf $m
        echo -n ${Color_arr[$m]}" "

tput sgr0
cat /sys/module/vt/parameters/default_red \
    /sys/module/vt/parameters/default_grn \
    /sys/module/vt/parameters/default_blu | sed s/,0/", "/g | \
    sed s/^0/" "/g | \
    tr "," "\t"

Second, you can do a lot more with ls than just --color=auto. But, it requires some work to sort everything out. I wrote a script to facilitate understanding, as well as to colorize files (based on their extensions) in a systematic way.

If it's too long to be pasted, check it out here.


# must be sourced

# see `man dircolors`
# in particular `dircolors -p > coldb.txt` (-p, --print-database)

# attributes
# 00 = none
# 01 = bold (bright)
# 04 = underscore (white; disables color code)
# 05 = blink (gray background)
# 07 = reverse (color as background)
# 08 = concealed (doesn't do anything)

# colors
R='00;31' # red
G='00;32' # green
Y='00;33' # yellow (brown in my console)
B='00;34' # blue
M='00;35' # magenta
C='00;36' # cyan
W='00;37' # white

# bold (bright)
BR='01;31' # red
BG='01;32' # green
BY='01;33' # yellow
BB='01;34' # blue
BM='01;35' # magenta
BC='01;36' # cyan
BW='01;37' # white

# for di (below) and possible some others
BL='00;30' # black
GR='01;30' # gray

# background
BGBL='40' # blue
BGRE='41' # red
BGGR='42' # green
BGYE='43' # yellow
BGBL='44' # blue
BGMA='45' # magenta
BGCY='46' # cyan
BGWH='47' # white

RS="rs=0"         # reset
DI="di=$BB"       # directory
LN="ln=$C"        # link
MH="mh=00"        # multihardlink (file with more than one link)
PI="pi=$BY;$BGBL" # pipe (FIFO)
SO="so=$BM"       # socket
DO="do=$BM"       # door
BD="bd=$BY;$GBBL" # block device driver
CD="cd=$BY;$BGBL" # character device driver
OR="or=$BR"       # symlink to nonexistent (or non-stat'able) file
SU="su=$W;$BGRE"  # file that is setuid (u+s)
SG="sg=$BL;$BGYE" # file that is setgid (g+s)
CA="ca=$BL;$BGRE" # file with capability
TW="tw=$BL;$BGGR" # dir that is sticky and other-writable (+t,o+w)
OW="ow=$BB;$BGGR" # dir that is other-writable (o+w) and not sticky
ST="st=$BW;$BGBL" # sticky bit dir (+t) and not other-writable
EX="ex=$BG"       # file with execute permission




export LS_COLORS
share|improve this answer

You can also use cope for this.

cope is a wrapper around programs that output to a terminal, to give them colour for utility and aesthetics while still keeping them the same at the text level.
share|improve this answer
Thank for that solution. It's almost the same thing than 'cw', except that, IMO, cw is easier to install. But it's same colors and almost same fields highlight. Moreover, cw has almost a hundred of possible commands, whereas cope has ~40. – Guillaume Fenollar Nov 23 '12 at 14:05
up vote 5 down vote accepted

Thank guys for all the replies, but no one matched my needs. I wanted something non-intrusive, and I found it in cw. This is a nice soft that you need to add in the begining of your PATH. So of course, it doesn't work with every command (only the ones already defined), but the result looks very nice! Check it out if you're interested:

share|improve this answer

Something I've often done is pipe the output of commands or log files that don't use colour themselves through a little script that colourizes them according to rules matching certain text. Perl is particularly good at this.

Here's a little example:

#!/usr/bin/perl -n

  $exp = shift @ARGV;
  $color = shift @ARGV;
  die "Use: colourize regexp colour" unless $color;

if (/$exp/) {


if (/$exp/) {
  print "\e[0m";

Save this as colourize somewhere in your PATH, chmod +x it and you can do things like

command | colourize WARNING 31

to have all lines containing WARNING printed in red. The number 31 is the ANSI colour code for red.

share|improve this answer

Try testing this :

for i in {0..7};
    tput setaf $i;
    echo "tput setaf $i";
    tput sgr0;

See terminalcodes and stuff:

share|improve this answer

Your Answer


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.