Created
September 23, 2015 17:38
-
-
Save scemama/43078b8348c1cc3401fb to your computer and use it in GitHub Desktop.
Timer in the bash prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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