Scatterbrains: git as biographer

[Tweet : nvALT]

This is another of my attempts at keeping track of my day in an orderly fashion. It’s a pretty simple idea. Given that most of of what I do is stored in git repositories, my commit logs are my best bet for seeing what I’ve accomplished each day. I just needed to pull them together and bundle them up without having to think about it. If a lot of your work happens in git repositories and you make frequent commits, this might be of use to you.

This script runs nightly and visits a list of local git repositories to extract a log of any commits for the day. It formats them as Markdown and can log them to Day One or just to a plain text file (single file, appended). There’s an accompanying shell command for easily adding the current directory as a repo to check.

This is what my log looks like in nvALT (with a custom theme):

GitLogger Screenshot

Git notes are included, as is body text of the commit if it exists. Formatting creates an unordered list, and short hashes for the commits are added at the end of the commit message, just in case you need them.

As usual, if you’re interested in trying it, I’m happy to share…

Automatic installation

You can use the following command to automatically install the script and have it run at 11:50pm daily:

/usr/bin/ruby -e "$(/usr/bin/curl -fsSL"

Manual install

  • Save the script below (gist link) as gitlogger.rb in a script or bin folder on your drive.
  • Use the variables at the top to set it up for logging to Day One (dayone = true), or enter a path to a text file (textlog = "path/to/"). If you don’t want to use text file logging, just set that option to “false”.
  • If you’re logging to Day One, see this post for more instructions. This script doesn’t need the dayone CLI tool, but if you’re not using iCloud for storing your journal, you’ll need to modify the paths to point to your journal file.

The second little script (gist link) is a bash function for adding whatever directory I’m working in to the list that the logger uses to find repos for logging. For consistent results in building the repo list, run the glog command from the base directory of the git repository. Set it once and forget it. You can remove repos from logging by editing the file at ~/.gitlogger. You can also just create that file by hand: each line is a repo, with the title first, followed by a colon, followed by the path.

  • Add this function to your ~/.bash_profile to be able to mark the current directory for logging by typing glog Alias, where “Alias” is the name you want to appear for the repo in your log.


To automate the script, I suggest using launchd (the OS X version of cron). Use Lingon or copy the code below into a file called com.yourusername.gitlogger.plist and save it in ~/Library/LaunchAgents/. After creating the file, you’ll want to run launchctl load ~/Library/LaunchAgents/com.yourusername.gitlogger.plist to get it started (or log out and back in, but that takes too long). The code as is will set up the logger to run at 11:50pm every night (in your local time). You’ll want to edit the Label and the ProgramArguments values to match your setup.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Maybe this will be of use to somebody. Code contributions and suggestions welcome, just follow the links on the gists above to fork. My personal git workflow works well with this logging statement, but you might want to modify it to log tags only, etc. Let me know what you do with it!