Created
March 8, 2013 01:27
-
-
Save mahemoff/5113522 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
########################################################################## | |
# library | |
########################################################################## | |
# via http://stackoverflow.com/a/12199798/18706 | |
function format_date { | |
((h=${1}/3600)) | |
((m=(${1}%3600)/60)) | |
((s=${1}%60)) | |
printf "%02d:%02d:%02d\n" $h $m $s | |
} | |
start=$(date +"%s") | |
function age { | |
now=$(date +"%s") | |
the_age=$(($now-$start)) | |
format_date $the_age | |
} | |
function announce { | |
echo `age`" ${FUNCNAME[ 1 ]} $1" | |
} | |
########################################################################## | |
# example | |
########################################################################## | |
function setup { | |
announce | |
sleep 5 | |
} | |
function finish { | |
announce | |
} | |
# this will output | |
# 00:00:00 setup | |
# 00:00:05 finish |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment