Debian lenny Colorful Bash prompt and file names

March 25th, 2010 | 1 Comment | Posted in Misc

Fancy bash and ls color is helpful feature in linux. Once we install Debian lenny, the bash prompt and ls result will show in normal ( black and white ). so i planed to make some changes in the profile file. This will helpful for Linux server administrators.

To change in to a colorful prompt do following,

Open /etc/profile

It is as follows.

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), …).

if [ "`id -u`" -eq 0 ]; then
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
else
PATH=”/usr/local/bin:/usr/bin:/bin:/usr/games”
fi

if [ "$PS1" ]; then
if [ "$BASH" ]; then
PS1=’\u@\h:\w\$ ‘
else
if [ "`id -u`" -eq 0 ]; then
PS1=’# ‘
else
PS1=’$ ‘
fi
fi
fi

export PATH

umask 022

Now, we have to replace Line PS1=’\u@\h:\w\$ ‘ with following code

if [[ ${EUID} == 0 ]] ; then
PS1=’${debian_chroot:+($debian_chroot)}\[\033[0;31m\]\u\[\033[1;37m\]@\[\033[1;34m\]\h\[\033[1;37m\]:\[\033[1;31m\]\w \[\033[1;36m\]\$ \[\033[0m\]‘
else
PS1=’\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] ‘
fi

alias ls=’ls –color=auto’
alias grep=’grep –colour=auto’

After the Changes File look like this

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), …).

if [ "`id -u`" -eq 0 ]; then
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
else
PATH=”/usr/local/bin:/usr/bin:/bin:/usr/games”
fi

if [ "$PS1" ]; then
if [ "$BASH" ]; then

if [[ ${EUID} == 0 ]] ; then
PS1=’${debian_chroot:+($debian_chroot)}\[\033[0;31m\]\u\[\033[1;37m\]@\[\033[1;34m\]\h\[\033[1;37m\]:\[\033[1;31m\]\w \[\033[1;36m\]\$ \[\033[0m\]‘
else
PS1=’\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] ‘
fi

alias ls=’ls –color=auto’
alias grep=’grep –colour=auto’

else
if [ "`id -u`" -eq 0 ]; then
PS1=’# ‘
else
PS1=’$ ‘
fi
fi
fi

export PATH

umask 022

If User have a .bashrc Then find the following line and comment it

#export PS1=’\h:\w\$ ‘

Now restart / reload the profile

See the result

Leave a Reply 5706 views, 4 today |
Tags: , , ,

Author :

I am a Technology Blogger, I Blog about technology related articles, Active in online and offline tech communities
Follow Discussion

One Response to “Debian lenny Colorful Bash prompt and file names”

  1. Arun kumar Says:

    Good article ,its very helpful.

Leave a Reply

You must be logged in to post a comment.


More in Misc (17 of 33 articles)