Skip to content

Commit 9b5596e

Browse files
committed
Update delay for snake spinner to 10 steps in 1 second
1 parent 04ba403 commit 9b5596e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

git-commit-push-script.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,24 @@ snake_spinner() {
3939
local frames=('' '' '' '' '' '' '' '')
4040
local col_arr=("$CYAN" "$BLUE" "$PURPLE" "$CYAN" "$BLUE" "$PURPLE" "$CYAN" "$BLUE")
4141
local nf=${#frames[@]}
42-
local ncol=${#col_arr[@]}
4342
local i=0 step=0
44-
local delay=0.08
45-
local elapsed="0.0"
43+
# 0.1s delay → 10 steps = 1s; use pure bash integer math (no bc fork)
44+
local delay=0.1
4645

4746
while true; do
48-
if [ "$pid" -ne 0 ] && ! ps -p "$pid" > /dev/null 2>&1; then
47+
# kill -0 is a bash builtin — no subprocess fork unlike ps -p
48+
if [ "$pid" -ne 0 ] && ! kill -0 "$pid" 2>/dev/null; then
4949
break
5050
fi
5151

52+
local secs=$(( step / 10 ))
53+
local tenths=$(( step % 10 ))
5254
local c="${col_arr[$i]}"
53-
printf "\r${c}${frames[$i]}${NC} ${WHITE}${label}${NC}${GRAY}...${NC} ${DIM}(${elapsed}s)${NC} "
55+
printf "\r${c}${frames[$i]}${NC} ${WHITE}${label}${NC}${GRAY}...${NC} ${DIM}(${secs}.${tenths}s)${NC} "
5456

5557
sleep "$delay"
5658
i=$(( (i + 1) % nf ))
5759
step=$(( step + 1 ))
58-
elapsed=$(echo "scale=1; $step * $delay" | bc)
5960
done
6061
printf "\r${GREEN}${NC} ${WHITE}Done!${NC} \n"
6162
}

0 commit comments

Comments
 (0)