Elapsed and execution time display for commands in ZSH
Append this to your ~/.zshrc file.
function preexec() {
timer=$(($(date +%s%0N)/1000000))
}
function precmd() {
if [ $timer ]; then
now=$(($(date +%s%0N)/1000000))
elapsed=$(($now-$timer))
export RPROMPT="%F{cyan}${elapsed}ms %{$reset_color%}"
unset timer
fi
}
Remixed from @adri's snippet.
Just to keep the "quick install" for Mac on this Gist.
Use Homebrew to install
coreutils
:Then update
date
togdate
. The snippet becomes: