Skip to content

Instantly share code, notes, and snippets.

@Serpens
Last active November 16, 2015 12:43
Show Gist options
  • Save Serpens/0a3ca9d1559a096edae4 to your computer and use it in GitHub Desktop.
Save Serpens/0a3ca9d1559a096edae4 to your computer and use it in GitHub Desktop.
Show execution time for commands that run for longer than 60 seconds.
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