diff --git a/src/init/starship.bash b/src/init/starship.bash index 05533527..14902be1 100644 --- a/src/init/starship.bash +++ b/src/init/starship.bash @@ -31,11 +31,11 @@ starship_precmd() { # Save the status, because commands in this pipeline will change $? STARSHIP_CMD_STATUS=$? - local NUM_JOBS + local NUM_JOBS=0 # Evaluate the number of jobs before running the preseved prompt command, so that tools # like z/autojump, which background certain jobs, do not cause spurious background jobs - # to be displayed by starship. Also avoids forking to run `wc`, slightly improving perf - NUM_JOBS=$(n=0; while read line; do [[ $line ]] && n=$((n+1));done <<< $(jobs -p) ; echo $n) + # to be displayed by starship. Also avoids forking to run `wc`, slightly improving perf. + for job in $(jobs -p); do [[ $job ]] && ((NUM_JOBS++)); done # Run the bash precmd function, if it's set. If not set, evaluates to no-op "${starship_precmd_user_func-:}"