Simple CLI Based Timer Alias

Here's a quick alias that will start up a timer and report the total time after a control-C.

alias timer='which banner>/dev/null 2>&1;[ $? -eq 0 ]&&c=banner||c=echo;export ts=$(date +%s);p='\''$(date -u -d @"$(($(date +%s)-$ts))" +"%H.%M.%S")'\'';watch -n 1 -t $c $p;eval "echo $p"'

This is a Mac version of the same thing, requires at least watch to be installed:

alias timer='which banner>/dev/null 2>&1;[ $? -eq 0 ]&&c=banner||c=echo;export ts=$(date +%s);p='\''$(date -u -r "$(($(date +%s)-$ts))" +"%H.%M.%S")'\'';watch -n 1 -t $c $p;eval "echo $p"'

Both versions checks whether or not banner is installed, if it is you should see:

 ####    ####           ####    ####           ####   #####
#   ##  #   ##         #   ##  #   ##         #   ##      #
#  # #  #  # #         #  # #  #  # #         #  # #     #
# #  #  # #  #         # #  #  # #  #         # #  #    #
##   #  ##   #   ###   ##   #  ##   #   ###   ##   #   #
#    #  #    #   ###   #    #  #    #   ###   #    #   #
 ####    ####    ###    ####    ####    ###    ####    #

Otherwise it will use echo:

00.01.51

Toss that in your .profile for quick access to a CLI timer.