I'm customizing my zsh prompt and have found the following to check if there are any background jobs:
if [[ $(jobs | wc -l) -gt 0 ]]; then # has background job(s)
number_jobs='J:${cyan}%j${no_color}'
else # no background job(s)
number_jobs=""
fi
The problem I'm facing is that the code appears to be evaluated only when I open a new session rather than after each command making this rather useless. How can I have number_jobs
re-evaluated after each command?