zsh: recolor prompt symbol dynamically

This commit is contained in:
Max Headroom 2022-03-06 01:03:53 +01:00
parent 5397db3d0e
commit 0c0312a5c3

View file

@ -11,7 +11,14 @@
# #
delta_prompt_symbol() { delta_prompt_symbol() {
if [[ "$1" -eq 0 ]]; then if [[ "$1" -eq 0 ]]; then
print -n "%F{$2}" local symbol_color
if [[ -n "$IN_NIX3_SHELL" || -n "$IN_NIX_SHELL" ]]; then
symbol_color=blue
else
symbol_color=red
fi
print -n "%F{$symbol_color}"
else else
print -n '%F{8}' print -n '%F{8}'
fi fi
@ -40,17 +47,10 @@ delta_prompt_init() {
hostnamevar='%m' hostnamevar='%m'
fi fi
local symbol_color
if [[ -n "$IN_NIX3_SHELL" || -n "$IN_NIX_SHELL" ]]; then
symbol_color=blue
else
symbol_color=red
fi
if [[ -n $SSH_CONNECTION ]]; then if [[ -n $SSH_CONNECTION ]]; then
PROMPT=" \$(delta_prompt_symbol \$? $symbol_color)Δ%f %F{8}$hostnamevar %c >%f " PROMPT=" \$(delta_prompt_symbol \$?)Δ%f %F{8}$hostnamevar %c >%f "
else else
PROMPT=" \$(delta_prompt_symbol \$? $symbol_color)Δ%f %F{8}%c >%f " PROMPT=" \$(delta_prompt_symbol \$?)Δ%f %F{8}%c >%f "
fi fi
zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' enable git