Can I have automatic color output for ls
if my TERM
environment variable is set to xterm-256color
?
2 Answers
If you are using bash, you could add export CLICOLOR="YES"
to your ~/.bashrc
.
-
-
1
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 |