bug-coreutils
[Top][All Lists]
Advanced

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

Re: patch: use color mode if CLICOLOR is set


From: Bob Proulx
Subject: Re: patch: use color mode if CLICOLOR is set
Date: Wed, 19 Mar 2003 11:40:31 -0700
User-agent: Mutt/1.3.28i

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




reply via email to

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