-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 57dd075
Showing
2 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Shell interval training timer | ||
============================= | ||
|
||
A small shell script for doing [interval training](http://en.wikipedia.org/wiki/Interval_training) | ||
(or circuit training) coveniently from your desk. I was inspired to write this quick script after | ||
reading the | ||
[NY Times "The Scientific 7-Minute Workout"](http://well.blogs.nytimes.com/2013/05/09/the-scientific-7-minute-workout/) | ||
article covering the | ||
[HICT work by Kilka & Jordan](http://journals.lww.com/acsm-healthfitness/Fulltext/2013/05000/HIGH_INTENSITY_CIRCUIT_TRAINING_USING_BODY_WEIGHT_.5.aspx). | ||
The workout from the that manuscript is the default for this script. | ||
|
||
### How it works | ||
|
||
The shell script loops through list of exercises (potentially user-supplied) | ||
and announces each one using the [`say` command](http://www.unix.com/man-page/osx/1/SAY/). | ||
The script sleeps between exercises using the | ||
[`sleep` command](http://www.unix.com/man-page/osx/1/sleep/). | ||
|
||
It has only been tested on Mac OSX. | ||
|
||
### Usage | ||
|
||
First, you probably want to make the script executable | ||
|
||
chmod a+x ./workout.sh | ||
|
||
Do the default workout | ||
|
||
./workout.sh | ||
|
||
Or, you can supply a file with your own exercises, 1 per line | ||
|
||
./workout.sh my-exercises.txt | ||
|
||
Finally, here's how you would supply a file with your own exercises, | ||
1 per line and do each for 45 seconds, resting for 20. | ||
|
||
./workout.sh my-exercises.txt 45 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# workout.sh - An audio timer for interval workouts on the mac | ||
# | ||
# Usage: | ||
# | ||
# # Do the default workout | ||
# ./workout.sh | ||
# | ||
# | ||
# # Supply a file with your own exercises, 1 per line | ||
# ./workout.sh my-exercises.txt | ||
# | ||
# | ||
# # Supply a file with your own exercises, 1 per line | ||
# # and do each for 45 seconds, resting for 20 | ||
# ./workout.sh my-exercises.txt 45 20 | ||
# | ||
|
||
# Use the default exercises or read in user specified exercises | ||
# | ||
if [ -z "$1" ]; then | ||
|
||
EXERCISES=( | ||
"jumping jacks" | ||
"wall sit" | ||
"push ups" | ||
"abdominal crunch" | ||
"chair step-up" | ||
"squats" | ||
"triceps dip on chair" | ||
"plank on floor" | ||
"high knee running" | ||
"lunge" | ||
"push-ups with rotating arms" | ||
"side plank" | ||
) | ||
else | ||
|
||
# Need to swap out IFS in case there are spaces | ||
# in the exercise names. | ||
OLD_IFS=$IFS | ||
IFS=$'\n' | ||
EXERCISES=( $(cat "$1") ) | ||
IFS=$OLD_IFS | ||
fi | ||
|
||
|
||
# Use the default intervals or get user-specified ones | ||
# | ||
default_exercise_interval=30 | ||
default_rest_interval=30 | ||
if [ -z "$2" ]; then | ||
exercise_interval=default_exercise_interval | ||
rest_interval=default_rest_interval | ||
else | ||
exercise_interval=$2 | ||
if [ -z "$3" ]; then | ||
rest_interval=default_rest_interval | ||
else | ||
rest_interval=$3 | ||
fi | ||
fi | ||
|
||
|
||
# Get ready | ||
# | ||
say "Ready?" | ||
sleep 2 | ||
|
||
|
||
NUM_EXERCISES=${#EXERCISES[@]} | ||
for (( i = 0; i < ${NUM_EXERCISES}; i++ )); do | ||
|
||
# Do the excersize | ||
# | ||
exercise=${EXERCISES[$i]} | ||
say "$exercise for $exercise_interval seconds, Go!" | ||
sleep 5 | ||
|
||
# Rest or finish up | ||
# | ||
if [[ $i != $((${NUM_EXERCISES} - 1)) ]]; then | ||
say "Rest $rest_interval seconds" | ||
sleep 10 | ||
else | ||
say "Done!" | ||
fi | ||
done |