NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

color last? (was Re: ls output with color?)

On Tue, May 15, 2012 at 04:35:07AM +0000, S.P.Zeidler wrote:
> (Aleksey Cheusov) writes:
> >On Mon, May 14, 2012 at 12:48 AM, Michael Jensen 
> ><> wrote:
> >> Another +1 to that. I hate ANSI colours in any standard command. Keep it
> >> simple.
> >There are people who prefer monochrome output of commands.
> >Personally, I prefer coloful prompt and output of make, configure, ls and so 
> >on
> >because colors helps me to do my job better. And there are people like me.
> >Colors implemented *inside* of ls, make and others like GNU does
> >is really stupid idea and nobody is tries to do this in NetBSD.
> >So, what's the problem?
> There's no problem if it -can- do color. There's only a problem if it
> assumes the user terminal has a specific background color and the user
> a specific acuity of vision and just does color by default. Cyan on pale
> yellow, gah.

It seems to me that the problem at bottom is that the colors are chosen
in the wrong place.  Just for example, recently I used some Linux box
that comes with a color grep as well as a color ls.  Color grep uses a
color to highlight strings matching your regular expression.  Both are
useful until and unless I use a pager:

        grep -i install README          -> color!
        grep -i install README | less   -> no color

grep is of course switching color on/off based on isatty(STDOUT_FILENO)
and other factors, and less isnotatty. :-) [1]

There should be a "late binding" of colors[2] to semantic items directly
before display.  The semantic items can be indicated using markup, e.g.,

        % grep -i install README
        To <grep:match>install</grep:match> Qubert, run ./configure ; make ; 
make install

The colors can be given with a stylesheet that's associated NOT with the
program but with the display, e.g.,

        @namespace grep url(;
        grep|match { color: green; }

Since the stylesheet is associated with the display, I think that it's
easier to make it self-consistent: no white on white text!


[1] I think that fewer programs than use isatty(3) today should use it
    in the future.  Maybe we should leave it up to the shell both to
    query the output device with isatty(3) and to adapt program outputs
    to program inputs in a pipeline.

[2] Colors or other styles.  Regular-expression matches could be bold,
    tall, italic, all-caps, or whatever style makes them stand out.

David Young    Urbana, IL    (217) 721-9981

Home | Main Index | Thread Index | Old Index