Skip to content

Instantly share code, notes, and snippets.

@nikhita
Created April 24, 2017 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikhita/c3736a2cf9f116d555d5acf59794920a to your computer and use it in GitHub Desktop.
Save nikhita/c3736a2cf9f116d555d5acf59794920a to your computer and use it in GitHub Desktop.
A script to show how long a command took to run. Outputs the time on the right.
function preexec() {
timer=${timer:-$SECONDS}
}
function precmd() {
if [ $timer ]; then
timer_show=$(($SECONDS - $timer))
export RPROMPT="%F{cyan}${timer_show}s %{$reset_color%}"
unset timer
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment