https://x.com/swyx/status/1677180561411153920
swyx @swyx[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.Jul 7, 2023 View on X →
Friday, July 7, 2023
