Determine host color through hash function
This commit is contained in:
parent
d09fb02b4f
commit
f6bd74b0f2
41
.bashrc
41
.bashrc
@ -37,37 +37,30 @@ shopt -s histappend
|
||||
set -C
|
||||
|
||||
PS1=""
|
||||
case "$HOSTNAME" in
|
||||
meret)
|
||||
PS_COLOR=37
|
||||
;;
|
||||
nout)
|
||||
PS_COLOR=36
|
||||
;;
|
||||
aton|bastet)
|
||||
PS_COLOR=35
|
||||
;;
|
||||
khonsou)
|
||||
PS_COLOR=34
|
||||
;;
|
||||
ptah|pc-mercie_d)
|
||||
PS_COLOR=33
|
||||
;;
|
||||
sekhmet)
|
||||
PS1="$PS1[\t] "
|
||||
PS_COLOR=32
|
||||
;;
|
||||
MD5CMD=`(which md5sum > /dev/null && echo "md5sum") ||
|
||||
(which md5 > /dev/null && echo "md5") || echo "cat"`
|
||||
|
||||
case `echo $(hostname) | $MD5CMD | sed -E 's/^.(.).*$/\1/'` in
|
||||
"1"|"6"|"b")
|
||||
HOST_COLOR=36 ;;
|
||||
"2"|"7"|"c")
|
||||
HOST_COLOR=32 ;;
|
||||
"3"|"8"|"d")
|
||||
HOST_COLOR=35 ;;
|
||||
"4"|"9"|"e")
|
||||
HOST_COLOR=34 ;;
|
||||
"5"|"a"|"f")
|
||||
HOST_COLOR=33 ;;
|
||||
*)
|
||||
PS_COLOR=30
|
||||
;;
|
||||
HOST_COLOR=37 ;;
|
||||
esac
|
||||
|
||||
if [ "$USER" == "root" ]; then
|
||||
PS_COLOR=31
|
||||
HOST_COLOR=31
|
||||
else
|
||||
PS1=$PS1"\u@"
|
||||
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'\$\[\033[0m\] '
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user