# codingtime: measure time for @/swapcoding with git

for the full @/swapcoding experience, i need to be able to measure time spent coding. i found a neater way to do it than using a dumb chess clock. do this:

  source <(curl -s https://iio.ie/gittime)

this installs two functions into the current shell. then the workflow in the game is the following:

works in both bash and zsh.

# implementation

gitstart just commits an empty commit with `start` as the sole commit message. gittime then simply adds up the time between the commits except for the start commits. the full source of the script is this:

loading... (needs javascript, check the js console for errors if this is not loading)

# example

the output looks something like this:

  min  task
  ---  ----
    3  initial project setup with source code and makefiles
    7  create the game state structures
   11  render the state into a nice interface
    6  add colors to the interface
    5  advance the state based on user prompt
    8  detect end of game state and quit

  total time:  0 h 40 m

the `min` column represents the elapsed minutes for the given task.

# background

so i had the opportunity to try swapcoding with a friend. we both created a simple terminal tic-tac-toe game. it had a nice, colorful terminal interface, an optimal ai player, player hints, etc. the experience was super fun and we achieved much more than i initially expected. it's something i totally want to try again. we did it without a clock but we really missed it. so i came up with this easy to share hack for the next time.

published on 2022-08-21



to the frontpage