reroll hostname prompt color if too dark
This commit is contained in:
parent
d1dd69b515
commit
16f294cbf2
|
@ -23,5 +23,23 @@ export IS_ROOT
|
||||||
export GPG_TTY=$(tty)
|
export GPG_TTY=$(tty)
|
||||||
gpg-connect-agent updatestartuptty /bye >/dev/null
|
gpg-connect-agent updatestartuptty /bye >/dev/null
|
||||||
|
|
||||||
# Color
|
# Color for hostname
|
||||||
export ZSH_THEME_HOSTNAME_COLOR="$(printf "%03d" "$(hostname | md5sum | head -c2)")"
|
function get_hostname_color () {
|
||||||
|
local col
|
||||||
|
for hash_func in md5sum sha1sum sha256sum; do
|
||||||
|
col="$(printf "%03d" "$((16#$(hostname | $hash_func | head -c2)))")"
|
||||||
|
if [[ $col -ne 0 ]] \
|
||||||
|
&& [[ $col -lt 16 || $col -gt 21 ]] \
|
||||||
|
&& [[ $col -lt 232 || $col -gt 243 ]]; then
|
||||||
|
# we found a color that isn't too dark
|
||||||
|
echo $col>>~/test.log
|
||||||
|
break
|
||||||
|
else
|
||||||
|
# default color
|
||||||
|
col="002"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
printf "$col"
|
||||||
|
}
|
||||||
|
export ZSH_THEME_HOSTNAME_COLOR="$(get_hostname_color)"
|
||||||
|
unset -f get_hostname_color
|
||||||
|
|
Loading…
Reference in New Issue