agnoster: improve perf with use of $jobstates (zsh/parameter module)

This saves multiple fork/execs (for the subshell and wc) each
time the prompt is rendered
This commit is contained in:
Andrew Baumann 2017-07-28 11:06:04 -07:00
commit 015e6242aa

View file

@ -29,6 +29,7 @@
# A few utility functions to make it easy and re-usable to draw segmented prompts
CURRENT_BG='NONE'
zmodload zsh/parameter
# Special Powerline characters
@ -207,7 +208,7 @@ prompt_status() {
symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
[[ ${#jobstates} -ne 0 ]] && symbols+="%{%F{cyan}%}⚙"
[[ -n "$symbols" ]] && prompt_segment black default "$symbols"
}