From bd1d3b91564576cc6d5b8c6c8eee9dfc68af915e Mon Sep 17 00:00:00 2001 From: Guillaume Dott Date: Fri, 5 Jul 2019 14:53:04 +0200 Subject: [PATCH] zsh: randomize prompt color according to hostname --- zsh/.zshrc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/zsh/.zshrc b/zsh/.zshrc index fad4299..feea1f3 100755 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -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%} '