Debian lenny Colorful Bash prompt and file names
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”
fiif [ "$PS1" ]; then
if [ "$BASH" ]; then
PS1=’\u@\h:\w\$ ‘
else
if [ "`id -u`" -eq 0 ]; then
PS1=’# ‘
else
PS1=’$ ‘
fi
fi
fiexport 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\] ‘
fialias 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”
fiif [ "$PS1" ]; then
if [ "$BASH" ]; thenif [[ ${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\] ‘
fialias ls=’ls –color=auto’
alias grep=’grep –colour=auto’else
if [ "`id -u`" -eq 0 ]; then
PS1=’# ‘
else
PS1=’$ ‘
fi
fi
fiexport 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









March 25th, 2010 at 3:24 PM
Good article ,its very helpful.