3

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

2 Answers 2

4

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

2
  • GHAAAAA! I set the variable up wrong! I set it to CLICOLORS!
    – CyberSkull
    May 23, 2013 at 21:25
  • 1
    You can also make use of the LS_COLORS var to customize the colors
    – demure
    May 23, 2013 at 21:27
4

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 |

You must log in to answer this question.

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