Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my .bashrc I have the following lines to turn on colors for grep and ls

alias ls='ls --color=auto'
export GREP_OPTIONS='--color=auto'

I've tried changing the alias to export LS_OPTIONS='--color=auto' but that doesn't work. Is there anyway to use an export instead of alias. And are there actually any benefits to one way over the other?

share|improve this question

migrated from Sep 15 '11 at 7:26

This question came from our site for professional and enthusiast programmers.

up vote 4 down vote accepted

Seems like LS_OPTIONS is more a Operating System startup configuration in some Linux/UNIX systems. ls won't read that variable, so it seems that the only viable option is the alias thing.

You can combine things to do what you want, though. For instance, just define ls as an alias like this:

alias ls='ls $LS_OPTIONS'

and then changing LS_OPTIONS will actually take effect immediately.

share|improve this answer

Unlike the Gnu grep command, the Gnu version of the ls command doesn't examine the environment variable LS_OPTIONS. Setting it doesn't do you any good unless you alias the ls command itself to use it:

$ alias ls="ls \$LS_OPTIONS"
$ ls      #Doesn't display color
$ export LS_OPTIONS="--color=auto"
$ ls      #Displays directory in color
$ unset LS_OPTIONS
$ ls      #Back to old behavior
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .