-
-
Save jamo/eae7ab7fd89c2a83c9cbada0ba49ec3f to your computer and use it in GitHub Desktop.
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
### Display execution time if command took longer than REPORTTIME_TOTAL | |
# | |
# https://superuser.com/a/847411/376927 | |
# | |
REPORTTIME_TOTAL=1 # seconds | |
cmd_execution_time() { | |
local stop=$((`date "+%s"`)) | |
let local "cmd_elapsed = ${stop} - ${cmd_start_time}" | |
let local "cmd_minutes = ${cmd_elapsed} / 60" | |
let local "cmd_seconds = ${cmd_elapsed} % 60" | |
(( $cmd_elapsed > $REPORTTIME_TOTAL )) && print -P "%F{yellow}${cmd_minutes} min ${cmd_seconds} sec%f" | |
} | |
preexec() { | |
cmd_start_time=$((`date "+%s"`)) | |
} | |
precmd() { | |
if (($+cmd_start_time)); then | |
cmd_execution_time | |
fi | |
} | |
### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment