Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Can I have automatic color output for ls if my TERM environment variable is set to xterm-256color?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

If you are using bash, you could add export CLICOLOR="YES" to your ~/.bashrc.

share|improve this answer
    
GHAAAAA! I set the variable up wrong! I set it to CLICOLORS! –  CyberSkull May 23 '13 at 21:25
1  
You can also make use of the LS_COLORS var to customize the colors –  demure May 23 '13 at 21:27

Just for the sake of anyone who might come along and wonder how to restrict this to only when the TERM is a certain value, you could put something like this in your shell's "rc" file (.zshrc or .bashrc etc):

case "$TERM" in 

    xterm-256color)
        export CLICOLOR="YES"
    ;;

    *color|xterm*)
        export CLICOLOR="YES"
    ;;

    vt100)
        export CLICOLOR="NO"
    ;;

esac

Note that the 2nd example is just there to show why you might want to use 'case' instead of 'if/then': the ability to use wildcard matching and use multiple entries separated by |

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.