From 0d3b2aaf128caf4451057ac2ef145cd51676fc62 Mon Sep 17 00:00:00 2001 From: Kevin Song <4605384+chipbuster@users.noreply.github.com> Date: Wed, 2 Dec 2020 01:48:13 -0600 Subject: [PATCH] style: Add comments for bash preexec fix (#1952) * Add comments for bash fix * Rewrite commend --- src/init/starship.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/init/starship.bash b/src/init/starship.bash index 587315572..a7e17045a 100644 --- a/src/init/starship.bash +++ b/src/init/starship.bash @@ -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