Skip to content

Instantly share code, notes, and snippets.

@slavaaaaaaaaaa
Forked from bldewolf/colorprompts.sh
Created April 2, 2015 22:23
Show Gist options
  • Save slavaaaaaaaaaa/b30a2a3fd91a617cdb88 to your computer and use it in GitHub Desktop.
Save slavaaaaaaaaaa/b30a2a3fd91a617cdb88 to your computer and use it in GitHub Desktop.
# /etc/skel/.bashrc
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
function _foreground_calc {
# reject these colors for being too dark
local reject=([0]=a [16]=a [17]=a [18]=a [19]=a [232]=a [233]=a [234]=a [235]=a [236]=a [237]=a [238]=a)
echo "$1" | shasum | while read -n2 num; do
local num=$((16#$num))
if [ -z "${reject[$num]}" ]; then
echo $num
return
fi
done
}
EDITOR="vim"
#hostnamecolor=$(hostname | od | tr ' ' '\n' | awk '{total = total + $1}END{print 30 + (total % 7)}')
hostnamecolor=$(_foreground_calc $HOSTNAME)
PS1='\[\e[32m\]\u@\[\e[38;5;${hostnamecolor}m\]\h \[\e[32m\]\w \j\[\e[0m\] \$ '
fortune | cowsay
echo "~~~~~~~~~~~^^^^^^^^^^^^^^^^^^~~~~~~~~~"
uptime
echo
screen -ls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment