zsh: randomize prompt color according to hostname

master
Guillaume Dott 2019-07-05 14:53:04 +02:00
parent f245213512
commit bd1d3b9156
1 changed files with 5 additions and 8 deletions

View File

@ -95,15 +95,12 @@ zle -N zle-keymap-select
if [ $(whoami) = "root" ]
then
if [ $USER = "root" ]
then COLOR="red"
else COLOR="blue"
fi
COLOR="red"
else
if [ -n "$SSH_CLIENT" ]
then COLOR="blue"
else COLOR="green"
fi
colors=(blue green cyan magenta yellow)
color_index=$(($(hostname | sum | cut -f1 -d" ") % $#colors + 1))
COLOR=$colors[$color_index]
fi
export PS1='%m%{$fg[$COLOR]%}:%{$reset_color%}%~${vcs_info_msg_0_}%{$fg[$COLOR]%}%#%{$reset_color%} '