blob: d574c496acb4b95bce5d54881d2d539bbeb02fdc (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#!/bin/rc
rfork en
exercises=()
session=()
reps=()
sets=()
wdir=$home/lib/fitness
today=`{date | awk '{print $3 tolower($2) $6}'}
t0=`{date | awk '{split($4, hms, /:/); print hms[1]":"hms[2]}'}
. <{<$wdir/exercises awk '/^[^ ]/ {print "exercises=($exercises ''"$0"'')"}'}
fn isnumber{
! ~ `{echo $1 | awk '/^[0-9]+$/'} ''
}
fn sanitize{
echo $1 | sed 's/[ ]#.*//g'
}
fn printexers{
for(i in `{seq 1 $#exercises})
echo $i':' $exercises($i)
}
fn printsession{
showreps=$1
showsets=$2
for(i in `{seq 1 $#session}){
echo -n $i':' $exercises($session($i))
if(~ $showreps 1 && ! ~ $#reps 0){
echo -n ' '[$reps($i)^x
if(~ $showsets 1 && ! ~ $#sets 0)
echo -n $sets($i)
echo -n ]
}
echo
}
}
fn plansession{
session=()
e=()
while(! ~ $e w){
echo program your workout session (a to add all, w to begin):
printexers | mc
e=`{read}
if(isnumber $e && test $e -ge 1 && test $e -le $#exercises)
session=($session $e)
if not if(~ $e a){
session=`{seq 1 $#exercises}
e=w
}
}
printsession | mc
echo -n is this all right?' '
ready=`{read}
if(~ $ready y)
setupreps
if not
plansession
}
fn setupreps{
reps=()
for(i in `{seq 1 $#session}){
r=()
while(! isnumber $r){
echo -n how many reps for $exercises($session($i))?' '
r=`{read}
r=`{sanitize $r}
}
reps=($reps $r)
}
printsession 1 | mc
echo -n is this all right?' '
ready=`{read}
if(~ $ready y)
start
if not
setupreps
}
fn mkreport{
t1=`{date | awk '{split($4, hms, /:/); print hms[1]":"hms[2]}'}
echo '#'exercise,reps,sets >$wdir/$today
for(i in `{seq 1 $#session})
if(! ~ $sets($i) 0)
echo $exercises($session($i))^,^$reps($i)^,^$sets($i) >>$wdir/$today
echo '#' session ran from $t0 to $t1 >>$wdir/$today
}
fn start{
# initialize the set array
for(i in `{seq 1 $#session})
sets=($sets 0)
while(! ~ $e q){
printsession 1 1 | mc
e=`{read}
if(isnumber $e && test $e -ge 1 && test $e -le $#session){
lo=`{echo $e-1 | bc}
hi=`{echo $e+1 | bc}
sets=($sets(1-$lo) `{echo $sets($e)+1 | bc} $sets($hi-))
}
}
mkreport
}
plansession
|