Plain counters for fast steps, and the tool’s own progress output
(git --progress, curl -#) for slow ones, since it already knows totals
and ETA. TTY only; piped output stays clean. Uses ok from
marker output.
TOTAL=3 N=0 # keep TOTAL equal to the number of stepsstep() { N=$((N + 1)); ok "[$N/$TOTAL] $1"; }
# single-line ticker for loops over many items; cleans up after itselftick() { [ -t 1 ] && printf "\r %2d/%d %s\033[K" "$1" "$2" "$3" || true; }tickend() { [ -t 1 ] && printf '\r\033[K' || true; }
# curl: progress bar on a TTY, silent when piped (stderr carries the bar)if [ -t 2 ]; then CURL="curl -f#L"; else CURL="curl -fsSL"; fi