logo       

Re: patch: use color mode if CLICOLOR is set: msg#00075

gnu.core-utils.bugs

Subject: Re: patch: use color mode if CLICOLOR is set

Michael Wardle wrote:
> 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.

How about something like this in your user shell cusomization?

if ls --version 2>/dev/null | grep -q -e fileutils -e coreutils; then
eval $(dircolors -b)
alias ls='ls --color=auto'
elif sometestforbsd; then
alias ls='ls -G'
fi

And, of course, the whole topic of color is one of personal
preference. A large can of worms for those who tread there.

Bob


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise