S
swyx @swyx
Friday, July 7, 2023 import

Tweet

[minor dev life pro tip] `brew install coreutils`, then add this to your .zshrc: ``` preexec() { timer=$(gdate +%s.%N) } precmd() { if [ -n "$timer" ]; then now=$(gdate +%s.%N) elapsed=$(echo "$now - $timer" | bc) timer_show=$(printf "%.2f" $elapsed) echo "Execution time: ${timer_show}s" unset timer fi } ``` prints execution time after every terminal command. never have to go back and rerun `time` again. be much more sensitive to latency spikes.