Vaibhav Singh

Blog - vaibhavsingh.com

Colourful bash shell

There are several ways to make bash present a colourful prompt as well as the file list. There are a plenty of tutorials on the web, Google for more.

Here is my ~/.bashrc and ~./bash_profile

# vi ~./bashrc
if [ "$TERM" != 'dumb' ] && [ -n "$BASH" ] && [ -n "$PS1" ]
then
        if [ `/usr/bin/whoami` = 'root' ]
        then
                export PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]'
         else
                export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
         fi
fi
#vi ~/.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
source ~/.bashrc

To setup system wide settings, enter them in /etc/profile. Note that sometimes the location or system files are customized for different distributions.

Further reading

This is a good article to read about how bash is invoked – what happens when you invoke bash [link].

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top