zsh: color prompt according to previous exit code
This commit is contained in:
parent
dbac417322
commit
1e0ac2b51b
1 changed files with 11 additions and 2 deletions
|
@ -30,6 +30,7 @@ typeset -gA icons=(
|
||||||
render_prompt() {
|
render_prompt() {
|
||||||
setopt localoptions shortloops
|
setopt localoptions shortloops
|
||||||
|
|
||||||
|
local separator="${zfg[faded]} ❯ "
|
||||||
local sections=(
|
local sections=(
|
||||||
"$(render_exit_code)"
|
"$(render_exit_code)"
|
||||||
"$(render_user_host)"
|
"$(render_user_host)"
|
||||||
|
@ -39,9 +40,17 @@ render_prompt() {
|
||||||
"$(render_jobs)"
|
"$(render_jobs)"
|
||||||
"$(render_exec_time)"
|
"$(render_exec_time)"
|
||||||
)
|
)
|
||||||
|
echo "${(@pj.$separator.)sections:#}${zfg[rst]}"
|
||||||
|
|
||||||
local separator="${zfg[faded]} ❯ "
|
local prompt_color
|
||||||
echo "${(@pj.$separator.)sections:#}${zfg[gray]}"
|
if ((PROMPT_EXIT_CODE == 0)); then
|
||||||
|
prompt_color="${zfg[faded]}"
|
||||||
|
elif ((PROMPT_EXIT_CODE > 128 && PROMPT_EXIT_CODE < 160)); then
|
||||||
|
prompt_color="${zfg[white]}"
|
||||||
|
else
|
||||||
|
prompt_color="${zfg[red]}"
|
||||||
|
fi
|
||||||
|
echo -n "$prompt_color"
|
||||||
(($SHLVL > 1)) && printf '%.0s' {2..$SHLVL}
|
(($SHLVL > 1)) && printf '%.0s' {2..$SHLVL}
|
||||||
echo -n "❯ ${zfg[rst]}"
|
echo -n "❯ ${zfg[rst]}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue