Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Sep 15 '11 at 7:26

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

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.