bug-coreutils
[Top][All Lists]
Advanced

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

patch: use color mode if CLICOLOR is set


From: Michael Wardle
Subject: patch: use color mode if CLICOLOR is set
Date: Wed, 19 Mar 2003 18:22:10 +1100

Hi

I work in a mixed environment of mostly FreeBSD, GNU/Linux, and IRIX
systems.  FreeBSD has a color ls that will enter color mode if the -G
option is specified or if the CLICOLOR environment variable is set.  GNU
has a color ls that will enter color mode if the --color option is
specified.  IRIX does not have a color ls mode.

In this environment, a simple shell alias such as "ls"="ls --color=auto"
to automatically colorize ls output will not suffice, as non-GNU
versions of ls do not understand the--color option.  I prefer the
FreeBSD approach, which is to use color mode if the CLICOLOR environment
variable is set, and if the output is a recognized terminal type,
similar to "--color=tty" in GNU ls.

The attached patch adds support for the CLICOLOR environment variable to
GNU ls.  If a --color option is specified, this overrides the value of
CLICOLOR.  I have tested this patch in all permutations of CLICOLOR set
and unset, --color specified and not specified, and output a TTY
and not a TTY (by piping the output to GNU less).

If you find this change useful, please let me know, and I will happily
add any necessary additions to the documentation.

PS: A case could also be made for automatic use of colorization if the
LS_COLORS environment variable is set.  I do not necessarily advocate
this, however the attached patch could easily be used to accomplish
this.

Thanks

-- 
Michael Wardle
Adacel Technologies

Attachment: ls-clicolor.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]