blob: 868803520474253ee356352f7892421e5c317479 (
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
|
#!/bin/rc
rfork en
exercises=()
session=()
reps=()
sets=()
wdir=$home/lib/fitness
today=`{date | awk '{print $3 tolower($2) $6}'}
. <{<$wdir/exercises awk '/^[^ ]/ {print "exercises=($exercises ''"$0"'')"}'}
fn isnumber{
! ~ `{echo $1 | awk '/^[0-9]+$/'} ''
}
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}
}
reps=($reps $r)
}
printsession 1 | mc
echo -n is this all right?' '
ready=`{read}
if(~ $ready y)
start
if not
setupreps
}
fn mkreport{
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
}
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
|