Skip to content

Instantly share code, notes, and snippets.

@scemama
Created September 23, 2015 17: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 scemama/43078b8348c1cc3401fb to your computer and use it in GitHub Desktop.
Save scemama/43078b8348c1cc3401fb to your computer and use it in GitHub Desktop.
Timer in the bash prompt
function timer_start {
timer=${timer:-$SECONDS}
}
function timer_stop {
timer_show=$(($SECONDS - $timer))
unset timer
}
trap 'timer_start' DEBUG
PROMPT_COMMAND=timer_stop
PS1='[last: ${timer_show}s][\w]$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment