Bash Prompt

This is my little mini script to put in /etc/bashrc to make your bash prompt colorful!

black="\033[0;30m\]"
red="\033[1;31m\]"
white="\033[1;37m\]"
blue="\033[0;34m\]"
green="\033[1;32m\]"
cyan="\033[1;36m\]"
yellow="\033[1;33m\]"
purple="\033[0;35m\]"
brown="\033[0;33m\]"
gray="\033[0;37m\]"
reset="\033[0m\]"

rootc=$red
userc=$cyan
hostc=$white
dirc=$yellow

if [ "$BASH" ]; then
        if [ "`id -u`" -eq 0 ]; then
                #Special prompt for root
                prompt="$rootc\u$gray@$hostc\h$dirc(\w)$reset\n:"
                PS1=$prompt
        else
                #Prompt for the rest of the users
                prompt="$userc\u$white@$hostc\h$dirc(\w)$reset\n:"
                PS1=$prompt
        fi
fi

export PATH PS1

On modern version of Fedora you can put this script in your /etc/profile.d directory

cd /etc/profile.d/ ; wget http://www.perturb.org/code/bash_prompt.sh ; cd -
Leave A Reply
All content licensed under the Creative Commons License