Ubuntu Pastebin

Paste from al at Tue, 21 Nov 2017 22:11:38 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash

SECONDS=0

"$@"

if [ $? -eq 0 ]; then
    RESULT="Succeeded"
else
    RESULT="Failed"
fi

#http://unix.stackexchange.com/a/175109/6940
seconds2time ()
{
   T=$1
   D=$((T/60/60/24))
   H=$((T/60/60%24))
   M=$((T/60%60))
   S=$((T%60))

   if [[ ${D} != 0 ]]
   then
      printf '%d days %02d:%02d:%02d' $D $H $M $S
   else
      printf '%02d:%02d:%02d' $H $M $S
   fi
}

if (( $SECONDS > 5 )); then
    NICETIME=$(seconds2time $SECONDS)
    notify-send "Command $RESULT" "CMD: $*\nPID: $$\nPWD: $PWD\nTime: $NICETIME"
fi
Download as text