Last active
November 16, 2015 12:43
-
-
Save Serpens/0a3ca9d1559a096edae4 to your computer and use it in GitHub Desktop.
Show execution time for commands that run for longer than 60 seconds.
This file contains 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
note_remind=0 | |
note_ignore="yes" | |
note_command="?" | |
note_report() | |
{ | |
echo "" | |
echo "note_report: $note_command completed in $1 seconds" | |
} | |
preexec() | |
{ | |
if [ "x$TTY" != "x" ]; then | |
note_remind="$SECONDS" | |
note_ignore="" | |
note_command="$2" | |
fi | |
} | |
precmd() | |
{ | |
local xx | |
if [ "x$TTY" != "x" ]; then | |
if [ "x$note_ignore" = "x" ]; then | |
note_ignore="yes" | |
xx=$(($SECONDS-$note_remind)) | |
if [ $xx -gt 60 ]; then | |
if [ $TTYIDLE -gt 60 ]; then | |
note_report $xx | |
fi | |
fi | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment