Skip to content

Instantly share code, notes, and snippets.

@rrmhearts
Created January 9, 2020 16:08
Show Gist options
  • Save rrmhearts/d4068d4ca517d8384a1153f2f8452e3f to your computer and use it in GitHub Desktop.
Save rrmhearts/d4068d4ca517d8384a1153f2f8452e3f to your computer and use it in GitHub Desktop.
Long bash
function long {
    START=$(date +%s.%N)
    $*
    EXIT_CODE=$?
    END=$(date +%s.%N)
    DIFF=$(echo "$END - $START" | bc)
    RES=$(python -c "diff = $DIFF; min = int(diff / 60); print('%s min' % min)")
    result="$1 completed in $RES, exit code $EXIT_CODE."
    echo -e "\n⏰  $result"
    ( say -r 250 $result 2>&1 > /dev/null & )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment