Skip to content

Commit 2a3adce

Browse files
committed
Added colored usernames based on md5sum of username
This'll help emphasize when I'm logged in as a different user.
1 parent 3be3b4d commit 2a3adce

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

zshrc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,30 @@ fi
5353

5454
PATH=/home/jgilmore/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/sbin:/usr/sbin
5555

56-
local head
56+
local head CH USERCOLOR MACHINECOLOR
57+
#Set the color of the username depending on the md5sum, so each username will have a different color. Don't do white or black.
58+
CH=1
59+
while USERCOLOR=`echo $USER | md5sum | cut -c $CH-$CH`; echo $USERCOLOR | grep '[07a-z]'>/dev/null; do
60+
CH=$(( $CH + 1 ));
61+
done
62+
63+
USERCOLOR="$fg[$color[3$USERCOLOR]]"
64+
5765
#If using ssh, set machine name to red.
5866
if [ "$SSH_TTY" ]; then
59-
head="%n@%{$fg_bold[red]%}%m%{$reset_color%}"
67+
MACHINECOLOR="$fg_bold[red]"
6068
else
61-
head='%n@%m'
69+
MACHINECOLOR="$reset_color"
6270
fi
63-
PROMPT="$head%3~%(?.%{$fg[green]%}:%).%{$fg[red]%} %? :()%{$reset_color%}%#"
71+
head="%{$USERCOLOR%}%n%{$reset_color%}@%{$MACHINECOLOR%}%m%{$reset_color%}"
72+
73+
PROMPT="$head%3~%(?.%{$fg[green]%}:%).%{$fg[red]%} %? :()%{$reset_color%}%#"
6474

6575
case $TERM in
6676
xterm*)
6777
precmd () {print -Pn "\e]0;zsh: %n@%m: %~\a"}
6878
preexec () { print -Pn "\e]0;zsh:%n@%m: %~,$1 \a" }
6979
;;
7080
esac
71-
81+
echo test
7282
fortune Scripture\ Mastery

0 commit comments

Comments
 (0)