style: Add comments for bash preexec fix (#1952)

* Add comments for bash fix

* Rewrite commend
This commit is contained in:
Kevin Song 2020-12-02 01:48:13 -06:00 committed by GitHub
parent ef311408db
commit 0d3b2aaf12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,6 +32,9 @@ starship_precmd() {
# Save the status, because commands in this pipeline will change $?
STATUS=$?
# 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)
# Run the bash precmd function, if it's set. If not set, evaluates to no-op