From: bl8n8r on
#!/bin/bash
#
# generates a randomly colored bash shell prompt and
# prints code to paste into .bashrc or shell.
#

NO_COLOUR="\033[0;0;00m"
LIMEBLACK="\033[0;30;42m"
GREEN="\033[0;32;40m"
BROWN="\033[0;33;40m"
BLUE="\033[0;34;40m"
GRAPE="\033[0;35;40m"
CYAN="\033[0;36;40m"
SILVER="\033[0;37;40m"
RED="\033[0;31;40m"
LIGHT_RED="\033[1;31;40m"
LIME="\033[1;32;40m"
YELLOW="\033[1;33;40m"
LIGHT_BLUE="\033[1;34;40m"
MAGENTA="\033[1;35;40m"
WHITE="\033[1;37;40m"
LIGHTCYAN="\033[1;36;40m"
YELLRED="\033[1;33;41m"
YELBLUE="\033[1;33;44m"
BLACKGRAY="\033[0;30;47m"
SILVERBLU="\033[1;37;44m"
LTCYANBLU="\033[1;36;44m"
MAGBLU="\033[1;35;44m"
LIMEBLUE="\033[1;32;44m"
YELMAG="\033[1;33;45m"
LTCYANMAG="\033[1;36;45m"
WHITEBLUE="\033[1;37;44m"
YELBROWN="\033[1;33;43m"
YELCYAN="\033[1;33;46m"
WHTCYAN="\033[1;37;46m"

Colors[0]="$LIMEBLACK"
Colors[1]="$GREEN"
Colors[2]="$BROWN"
Colors[3]="$BLUE"
Colors[4]="$GRAPE"
Colors[5]="$CYAN"
Colors[6]="$SILVER"
Colors[7]="$RED"
Colors[8]="$LIGHT_RED"
Colors[9]="$LIME"
Colors[10]="$YELLOW"
Colors[11]="$LIGHT_BLUE"
Colors[12]="$MAGENTA"
Colors[13]="$WHITE"
Colors[14]="$LIGHTCYAN"
Colors[15]="$YELBLUE"
Colors[16]="$BLACKGRAY"
Colors[17]="$SILVERBLU"
Colors[18]="$LTCYANBLU"
Colors[19]="$MAGBLU"
Colors[20]="$LIMEBLUE"
Colors[21]="$YELMAG"
Colors[22]="$LTCYANMAG"
Colors[23]="$WHITEBLUE"
Colors[24]="$YELBROWN"
Colors[25]="$YELCYAN"
Colors[26]="$WHTCYAN"



#---------------------------------------------------------#
# color of user and prompt character selection (# for su)
# root is always Yellow/Red
#---------------------------------------------------------#
case $LOGNAME in
root)
UC=$YELLRED
PCHAR='#'
;;

*)
UC=$CYAN
PCHAR='$'
;;
esac

#---------------------------------------------------------#
# host specific colors
#---------------------------------------------------------#
let R="$RANDOM%26"
BC=${Colors[$R]}

let R="$RANDOM%26"
TC=${Colors[$R]}

let R="$RANDOM%26"
DC=${Colors[$R]}

let R="$RANDOM%26"
HC=${Colors[$R]}

let R="$RANDOM%26"
PC=${Colors[$R]}

let R="$RANDOM%26"
SC=${Colors[$R]}

let R="$RANDOM%26"
AC=${Colors[$R]}


t=$(date +%I:%M)
d=$(date +%Y-%m-%d)
echo -e "
#----------------------------------------
# prompt preview
#----------------------------------------
$BC[$TC$t $DC$d$BC]$NO_COLOUR
$BC[$UC$LOGNAME$AC@$HC$HOSTNAME $PC$PWD$BC]$NO_COLOUR
${SILVER}${PCHAR}${NO_COLOUR} "

echo "#----------------------------------------
# prompt shellcode
#----------------------------------------
PCHAR='$'; UC=\"$UC\"
test \`id -u\` -eq 0 && PCHAR='#' && UC=\"$YELLRED\"
PS1=\"
$BC[$TC\$(date +%I:%M' $DC'%D)$BC]$NO_COLOUR
$BC[\$UC\u$AC@$HC\h $PC\w$BC]$NO_COLOUR
${SILVER}\${PCHAR}${NO_COLOUR} \" export PS1

"