How do I get ls to output a COLOR listing?
Some familiarity with the Athena dotfiles is assumed here; please
refer to http://web.mit.edu/olh/Dotfiles for more information.
1) Make sure your terminal can display color; gnome-terminal and xterm
on Linux should be able to. xterm on Suns does as of Athena 9.2, but
requires "XTerm*colorMode: true" in .Xresources. You can test this by
typing:
echo '^[[1;31mred'
where that first ^[ is produced by hitting control-v then escape.
An alternative terminal is rxvt in the outland locker.
2) (optional) Set the environment variable LS_COLORS, in your
~/.environment file; dircolors is a program that produces something you
can set it to.
If you use dircolors on both platforms, make sure to use the one in the
gnu locker explicitly, since on linux, there's a broken one in /usr/bin.
eval `athrun gnu dircolors -c`
should do the trick, but is admittedly a little cumbersome.
3) Set up aliases in your ~/.cshrc.mine, so that when you run ls, you are
running 'gls --color=auto' where gls is in the gnu locker, on suns only.
setenv MACHTYPE `/bin/athena/machtype`
setenv LS_OPTIONS '--color=auto'
if ($MACHTYPE == 'sun4') then
alias ls "gls $LS_OPTIONS"
else
alias ls "ls $LS_OPTIONS"
endif
(You might as well set $MACHTYPE in your ~/.environment, instead of
your ~/.cshrc.mine, and of course you need to have the gnu locker added
for gls.)
Note: Users of the bash shell should be able to translate this fairly
readily; in particular, you want `dircolors -b` and the one in /usr/bin
on linux won't hurt you.
Last updated: $Date: 2004/06/03 04:30:57 $
|