Command Prompt

# customize the prompt

if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then

# We have color support; assume it's compliant with Ecma-48

# (ISO/IEC-6429). (Lack of such support is extremely rare, and such

# a case would tend to support setf rather than setaf.)

dark_black_on='\[\e[0;30m\]'

dark_red_on='\[\e[0;31m\]'

dark_green_on='\[\e[0;32m\]'

dark_yellow_on='\[\e[0;33m\]'

dark_blue_on='\[\e[0;34m\]'

dark_purple_on='\[\e[0;35m\]'

dark_cyan_on='\[\e[0;36m\]'

dark_white_on='\[\e[0;37m\]'

bold_black_on='\[\e[01;30m\]'

bold_red_on='\[\e[01;31m\]'

bold_green_on='\[\e[01;32m\]'

bold_yellow_on='\[\e[01;33m\]'

bold_blue_on='\[\e[01;34m\]'

bold_purple_on='\[\e[01;35m\]'

bold_cyan_on='\[\e[01;36m\]'

bold_white_on='\[\e[01;37m\]'

black_on='\[\e[30m\]'

red_on='\[\e[31m\]'

green_on='\[\e[32m\]'

yellow_on='\[\e[33m\]'

blue_on='\[\e[34m\]'

purple_on='\[\e[35m\]'

cyan_on='\[\e[36m\]'

white_on='\[\e[37m\]'

color_off='\[\e[00m\]'

fi

function __duane_prompt_command() {

local EXIT="$?" # This needs to be first

local ERROR=""

if [ $EXIT != 0 ]; then

local ERROR=" $bold_red_on($EXIT)"

fi

PS1="$bold_red_on[$dark_blue_on\u$dark_black_on@$blue_on\h$dark_purple_on \w$ERROR$bold_red_on]$dark_red_on\$$color_off "

}

if [ "$PS1" ]; then

case $TERM in

xterm*)

if [ -e /etc/sysconfig/bash-prompt-xterm ]; then

PROMPT_COMMAND='__duane_prompt_command; /etc/sysconfig/bash-prompt-xterm'

else

PROMPT_COMMAND='__duane_prompt_command; printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'

fi

;;

screen)

if [ -e /etc/sysconfig/bash-prompt-screen ]; then

PROMPT_COMMAND='__duane_prompt_command; /etc/sysconfig/bash-prompt-screen'

else

PROMPT_COMMAND='__duane_prompt_command; printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'

fi

;;

*)

[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND='__duane_prompt_command; /etc/sysconfig/bash-prompt-default'

;;

esac

# Turn on checkwinsize

shopt -s checkwinsize

# call __duane_prompt_command() once if PROMPT_COMMAND is overridden by something that doesn't touch PS1

#__duane_prompt_command

fi