# - - - - - - - - - - - - - -
#    get some nice colors
# - - - - - - - - - - - - - -
source ~/.bash/colors

# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#    THRESHOLD_LOAD is the value of the 5 minute load
#    multiplied by 100 at which you want the prompt
#    to change from low to high
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
THRESHOLD_LOAD=200
COLOR_LOW="$COLOR_BLUE"
COLOR_HIGH="$COLOR_RED"

function prompt_command
{
ONE=$(uptime|cut -d " " -f 14 | cut -d "," -f1)
ONEHUNDRED=$(echo -e "scale=0 \n $ONE/0.01 \nquit \n" | bc)

if [ $ONEHUNDRED -gt $THRESHOLD_LOAD ]
then
	HOST_COLOR=$COLOR_HIGH
else
	HOST_COLOR=$COLOR_LOW
fi
}

function hostloadcolor
{
PROMPT_COMMAND=prompt_command
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - -
#    Know which window you are in when using screen
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
if test x"$WINDOW" != x""; then
        SCREEEN_NUM="($COLOR_BLUE$WINDOW$COLOR_WHITE)"
else
        SCREEEN_NUM=""
fi

# - - - - - - - - - - - - - - - - - -
#    Copied from /etc/bash/bashrc
# - - - - - - - - - - - - - - - - - -
if ${use_color} ; then
        if [[ ${EUID} == 0 ]] ; then
                PS1="$COLOR_BLUE[$COLOR_WHITE\W$COLOR_BLUE][$COLOR_GREY!$COLOR_WHITE\!$COLOR_BLUE][$COLOR_WHITE pts/\l$COLOR_BLUE ]$COLOR_GREEN\n\h $COLOR_WHITE${SCREEEN_NUM}$COLOR_BLUE\$$COLOR_NONE "
        else
                PS1="$COLOR_BLUE[$COLOR_WHITE\w$COLOR_BLUE][$COLOR_GREY!$COLOR_WHITE\!$COLOR_BLUE][$COLOR_WHITE pts/\l$COLOR_BLUE ]$COLOR_GREEN\n\u$COLOR_BLUE@$COLOR_GREEN\h $COLOR_WHITE${SCREEEN_NUM}$COLOR_BLUE\$$COLOR_NONE "
        fi

else
        if [[ ${EUID} == 0 ]] ; then
                # show root@ when we don't have colors
                PS1='\u@\h \W \$ '
        else
                PS1='\u@\h \w \$ '
        fi
fi

# - - - - - - - - - - - - - - - - - - - - -
#    command running changes screen name
# - - - - - - - - - - - - - - - - - - - - -
export PS1=$PS1'\[\033k\033\\\]'
