Per-host prompt colouring

Hashes the hostname to get a value 1-15 and uses that as the colour for
the hostname in the prompt.

Includes example theme (jms) which uses it
This commit is contained in:
James Seward 2013-12-03 15:41:57 +00:00
commit 788e1819d4
2 changed files with 56 additions and 0 deletions

View file

@ -15,3 +15,17 @@ function take() {
cd $1
}
function string_hash() {
HASHSTR=$1
HASHSIZE=$2
HASHVAL=0
for i in {1..${#HASHSTR}}; do;
THISCHAR=$HASHSTR[$i]
HASHVAL=$(( $HASHVAL + $((#THISCHAR)) ))
done
HASHSIZE=$(( $HASHSIZE - 1 ))
HASHVAL=$(( $HASHVAL % $HASHSIZE ))
HASHVAL=$(( $HASHVAL + 1 ))
echo $HASHVAL
}