Tuesday, August 11, 2009

Enabling color support of "ls" in Bash

I have noticed that executing ls command in "Terminal" and "Xterm" does not give me colorful output as in "Konsole". To get colorful output in these X terminals in bash, add below lines to your ~/.bashrc file and restart X terminal.

# enable color support of ls and add handy aliases
if [ "$TERM" != "dumb" ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'

fi

To enable the same function for your root shell, add above lines to /root/.bashrc file.




1 comment: