~mikini/hometools

ref: 637040b13e70a39c89ba1e76df7dfeed6a0fe916 hometools/stop_watch -rwxr-xr-x 876 bytes
637040b1 — Mikkel Kirkgaard Nielsen Add COPYING and README.md 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /bin/bash

#(START=$(date +%s);echo -en "Start: $(date -d @$START)\n"; while true; do NOW=$(date +%s);ELAPSED=$(($NOW-$START));ELAPSED_H=$(($ELAPSED/3600));ELAPSED_M=$(($ELAPSED/60));ELAPSED_S=$(($ELAPSED-$ELAPSED_H*3600-$ELAPSED_M*60));echo -en "\e[GNow: $(date -d @$NOW), Elapsed: $ELAPSED_H:$ELAPSED_M:$ELAPSED_S (PT${ELAPSED_H}H${ELAPSED_M}M${ELAPSED_S}S)"; sleep 1; done;)

function exith () {
    STOP=$(date +%s)
    echo -en "\nStop : $(date -d @$STOP)"
}

trap exith EXIT

START=$(date +%s)
echo -en "Start: $(date -d @$START)\n"
while true; do 
    NOW=$(date +%s)
    ELAPSED=$(($NOW-$START))
    ELAPSED_H=$(($ELAPSED/3600))
    ELAPSED_M=$(($ELAPSED/60))
    ELAPSED_S=$(($ELAPSED-$ELAPSED_H*3600-$ELAPSED_M*60))
    echo -en "\e[GNow  : $(date -d @$NOW), Elapsed: $ELAPSED_H:$ELAPSED_M:$ELAPSED_S (PT${ELAPSED_H}H${ELAPSED_M}M${ELAPSED_S}S)"
    sleep 1
done