fitrecs: a minimalist command-line fitness record keeper


fitrecs is a minimalist command-line fitness record keeper. What this means is that you keep your fitness records, and fitrecs will print them, format them, convert them, and otherwise manipulate them for you. It can also tell you personal records and totals.

NOTE: I have recently become aware that integer overflows can cause security problems. I don't think this is a likely problem for normal use cases (e.g., a single user on a single computer, using files that he knows), but I don't really have the bandwidth or the knowledge to guarantee this right now. So as always, use at your own risk.

fitrecs is:

Download

fitrecs is available for download at Codeberg:

fitrecs source

Usage

For the most part, fitrecs's man page should be pretty self-explanatory:

Man page (HTML)

The long and the short of it, however, is below.

Data File

fitrecs requires that you give it at least a data file; that is, a file which contains the records that you want it to process. The data file is a very simple format, reasonably error-tolerant; each line should be formatted as follows, with some whitespace (how much is irrelevant) between each element:

  1. The date. The date can come in a variety of formats:
  2. The name of the exercise; this can be any string of letters. Examples are “pushup”, ”situp”, “run”.
  3. The actual value; that is, how many pushups, or how long a run. These can come in any of four different types: counts, weights, distances, and times. Values and units may be freely mixed in your data file; e.g., you may use miles on one day and kilometers on another. fitrecs will not get confused. Some exercises include multiple values; for example, a run will likely include both a distance and a time. Put both! Just separate them with a semicolon (“;”).

And that's it! An extremely simple format for an extremely simple thing. If fitrecs can't figure out what you mean in a particular line of a data file, it will simply print the line that confuses it and move on; that way you still get all the rest of your data processed, and you're notified of what fitrecs couldn't understand.

Here are a couple of examples of valid data file lines:

2022-12-21	walk		51:05; 3.34mi
2022-12-21	pushup		26
2022-12-21	plank		1:00
2022-12-21	squat		20

We've chosen to put tabs between each element, so that they'd line up; but as long as there is some whitespace between each element, fitrecs will be fine.

Notice in the first line that both a time and a distance have been specified, separated by a semicolon. fitrecs understands that both of these belong to the same exercise and will keep them together accordingly; it can also use these values to calculate your speed and your pace, if you want it to do so, about which more in a moment.

Config File

You can also tell fitrecs how to behave with a config file. You can tell fitrecs what file to use for its configuration options on the command line, but by default it will use the file at $HOME/.config/fitrecs/fitrecsrc, unless you tell it otherwise.

This file is also very simply formatted, each line containing only two elements:

  1. A option name. This will be all-caps, possibly with one or more underscores, and will end with a colon (“:”). E.g., OUTPUT_DIST_UNIT:.
  2. The value. This will be a string of some sort.

And again, that's it! A very simple format for a very simple thing. Here's an example of a config file, which actually specifies every option that fitrecs recognizes:

OUTPUT_WGT_UNIT:	lbs
OUTPUT_DIST_UNIT:	mi
OUTPUT_TIME_UNIT:	default
OUTPUT_TIME_COMPOSITE:	hr
OUTPUT_DATE_FORMAT:	%2d %b %Y
PRECISION:		3
PRINT_SPEED:		true
PRINT_PACE:		true
PRINT_SUMMARY:		true
PRINT_TOTALS:		true

The amount of whitespace between the colon and the value is, of course, irrelevant; we've used tabs here to make them line up nicely, but you could use a space, or even nothing if you'd like.

You can put the following in your config file:

OUTPUT_WGT_UNIT:The weight unit for output.
OUTPUT_DIST_UNIT:The distance unit for output.
OUTPUT_TIME_UNIT:The time unit for output. Only used when time is the only thing being output; see below.
OUTPUT_TIME_COMPOSITE:The time unit for output in the composite units that fitrecs calculates; namely, speed and pace.
OUTPUT_DATE_FORMAT:The format to output dates in.
PRECISION:How many decimal places to print output.
PRINT_SPEED:Tells fitrecs to calculate and print speeds when the units to do so are available.
PRINT_PACE:Tells fitrecs to calculate and print paces when the units to do so are available.
PRINT_RECORDS:Tells fitrecs to calculate and print records—the highest value for a given exercise.
PRINT_TOTALS:Tells fitrecs to calculate and print totals—the sum of all values for a given exercise.
PRINT_SUMMARY:Tells fitrecs to print a general summary of the exercises in the database: types of exercises, number of each, and other sundry data.

Common Options

When you're running fitrecs, there are a few things that you'll probably want to do regularly. Let's look at a few of those.

$ > fitrecs -f datafile

The most obvious example. This will simply print out your records, in chronological order, and then quit. You can just look at what you've done, organized in a nice way.

$ > fitrecs -f datafile -Sp

This will do the same thing, but will also print out your speeds (-S) and your pace (-p) for any exercises that have the necessary quantities attached (that is, a distance and a time).

$ > fitrecs -f datafile -Sp -Rg

This will take your data, not print your individual records (-R), and then print a summary of your various exercises (-g). It will look something like this:

fake            1           5        05 Jan 2020            5        
weight         20     245.000lbs     22 Aug 2021     4065.592lbs     
walk           96       4.420mi      29 Oct 2022      292.588mi      
walk           96 01:27:22.00        08 Oct 2022  86:47:57.00        
walk           96       3.995mi/hr   29 Mar 2022      322.495mi/hr   
pushup         45          26        20 Dec 2022          786        
situp          24          24        16 Sep 2021          481        
squat          43          20        20 Dec 2022          620        
plank          42 00:01:10.00        27 Dec 2022  00:29:52.00        
jumping jacks   1          60        01 Oct 2022           60        
short run       1 00:30:00.00        01 Oct 2022  00:30:00.00        
chinup          9           3        13 Dec 2022           18        
pullup          8           1        01 Dec 2022            5        
run             1       1.000mi      03 Dec 2022        1.000mi      
run             1 00:11:00.00        03 Dec 2022  00:11:00.00        
run             1       5.455mi/hr   03 Dec 2022        5.455mi/hr   

Each exercise is printed with its number of entries; its top value; the date of that top value; and the sum total of all its values. This gives you a good idea of what you've been doing and what your totals are.

Conclusion

I hope that fitrecs is as useful to you as it has been to me.