Determine host color through hash function

This commit is contained in:
Némunaire 2013-12-28 16:36:48 +01:00
parent d09fb02b4f
commit f6bd74b0f2

41
.bashrc
View File

@ -37,37 +37,30 @@ shopt -s histappend
set -C set -C
PS1="" PS1=""
case "$HOSTNAME" in MD5CMD=`(which md5sum > /dev/null && echo "md5sum") ||
meret) (which md5 > /dev/null && echo "md5") || echo "cat"`
PS_COLOR=37
;; case `echo $(hostname) | $MD5CMD | sed -E 's/^.(.).*$/\1/'` in
nout) "1"|"6"|"b")
PS_COLOR=36 HOST_COLOR=36 ;;
;; "2"|"7"|"c")
aton|bastet) HOST_COLOR=32 ;;
PS_COLOR=35 "3"|"8"|"d")
;; HOST_COLOR=35 ;;
khonsou) "4"|"9"|"e")
PS_COLOR=34 HOST_COLOR=34 ;;
;; "5"|"a"|"f")
ptah|pc-mercie_d) HOST_COLOR=33 ;;
PS_COLOR=33
;;
sekhmet)
PS1="$PS1[\t] "
PS_COLOR=32
;;
*) *)
PS_COLOR=30 HOST_COLOR=37 ;;
;;
esac esac
if [ "$USER" == "root" ]; then if [ "$USER" == "root" ]; then
PS_COLOR=31 HOST_COLOR=31
else else
PS1=$PS1"\u@" PS1=$PS1"\u@"
fi fi
PS1=$PS1'\[\e[$PS_COLOR;01m\]\h\[\e[00m\]:\[\e[01;34m\]\W\[\e[00m\]' PS1=$PS1'\[\e[$HOST_COLOR;01m\]\h\[\e[00m\]:\[\e[01;34m\]\W\[\e[00m\]'
PS1=$PS1'\[`if [ $? -eq 0 ]; then echo -ne "\033[0;32m"; else echo -ne "\033[0;31m"; fi`\]' PS1=$PS1'\[`if [ $? -eq 0 ]; then echo -ne "\033[0;32m"; else echo -ne "\033[0;31m"; fi`\]'
PS1=$PS1'\$\[\033[0m\] ' PS1=$PS1'\$\[\033[0m\] '