[Eug-lug] To Horst-Q/colours

T. Joseph CARTER knghtbrd at bluecherry.net
Mon Jan 3 21:17:38 PST 2005


On Tue, Jan 04, 2005 at 03:03:36AM +0000, walter fry wrote:
> thanks 4 your interest.. My text.ed is GDM2 (gnome ver.=2.5.90.2 last 
> up.d.=2/12/4 ) I was using the right click in the fedora main screen which 
> says "open terminal" and that gives me a command line where I entered " ls 
> -lh " this gives me the permissions some text.. and some stuff in colour, 
> that is what got my interest, I wanted to know what it meant, and I was 
> wondering from where this colour coding was controled.

The ls command has some colour information stored internally if you use
the --color or --color=auto option to ls (your distribution is probably
set up to use --color=auto by default), but there is a command which
allows you to configure the colours, named appropriately "dircolors".

The way to run this command is "eval `dircolors`" (note the backticks)
either at the command prompt or in your ~/.bash_profile..  "man dircolors"
will tell you a bit more about the program and show you a little more
about using it.  To see what the config file for dircolors would look
like, use "dircolors --print-database | less" (the output is long, and
less will let you scroll up and down easily--it's like the dos command
more, except better..)

You can really tweak the output of ls in a lot of cool ways.  My standard
ls alias is "ls -F --color=auto", which uses both colour output for
interactive usage and adds an extra character for special files to help
you know what they are.  You'll probably recognize the numbers used in the
config file as being the same as the ones used by \e[<whatever>m code in
the message from this weekend, but I'll repeat the numbers below so that
you have the information in this context.


> That stuff about escape sequences is totally puzzeling to me
> particularly since I could not find any reference in any of my books.
> perhaps I'm just not smart enough to know how to look it up.

The escape sequences are a bit archaic, depend a bit on your terminal type
(though there is a standard set that works on nearly all terminals you'll
ever encounter), and is a throwback to the days when people had several
monitors and keyboards connected to a single big computer through serial
ports (and even further back than that actually!)  All you need to know to
configure dircolors are the numbers for the m code:

	30	black
	31	red
	32	green
	33	brown
	34	blue
	35	magenta
	36	cyan
	37	lt grey

Add ;1 to that these to make the colour brighter:

	30;1	dark grey
	31;1	bright red
	32;1	bright green
	33;1	yellow
	34;1	bright blue
	35;1	bright magenta
	36;1	bright cyan
	37;1	white

Instead of the using 30s, use 40s for background colour.  That's all you
should need to know for dircolors.

> There is soooo much stuff in there,  sometimes I wonder if it is really
> worth the trouble and frustration, to spend so much time in front of a
> dumb box of rocks and make such slow progress. It might be wiser to go
> back to my 286 where I was better than I am here.          

They say Linux is free if your time has no value.  For the time invested,
though, you learn about a set of tools that are largely the same ones that
were developed 35 years ago for getting serious work done, and are still
some of the most effective tools for that purpose.  The UNIX shell
environment is at times a scary thing for new users, but once you get the
hang of it and how easily you can do most anything you want with it, I
think you'll be hard pressed to imagine anything else as worthwhile, even
if it does seem simpler for the time being.



More information about the EUGLUG mailing list