메인 내용으로 이동

Timed Terminal Commands

Lesser Known Trick. Add this to ~/.zshrc or anything equivalent.

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 "⏱ ${timer_show}s"
unset timer
fi
}

이 문서를 언급한 문서들