Logging time, part 2: gtimelog on the commandline¶

Using github for timelogging is fine, but I longed back to the days when I used a hacked-up of gtimelog that worked on the commandline. I looked in my private git repository with my old subversion stuff and found it.

Why gtimelog? Well, in my case, on the commandline, it works quite well. Type in tl weblog on the commandline when I’ve written a blog entry. Type in tl ror_export when I’ve worked on that particular project. I’ve hooked up commandline completion. The end result is a timelog.txt file with a simple line-based format:

2013 - 04 - 16 09 : 36 : arrived ** 2013 - 04 - 16 10 : 08 : compu 2013 - 04 - 16 10 : 31 : omnifocus 2013 - 04 - 16 11 : 15 : neerslagradar 2013 - 04 - 16 11 : 37 : email_en_newsgroups 2013 - 04 - 16 11 : 50 : email_en_newsgroups 2013 - 04 - 16 12 : 30 : lizard_unbillable 2013 - 04 - 16 13 : 15 : lunch **

You can modify it afterwards if needed. Lightweight. I get a daily or weekly report out of it like this:

Blokkendoos 3 hours 24 min Compu 32 min Email_en_newsgroups 35 min Lizard_unbillable 2 hours 6 min Neerslagradar 44 min

The regular gtimelog requires gtk, which isn’t handy on OSX. On debian/ubuntu you can apt-get install it. You get a window-based interface that way and can click entries and have a constant overview and so. That said, I hacked up a modified version that only requires the commandline and provides two commands:

tl Add a timelog entry to the logfile. The entry to add is passed on the commandline, for instance tl weblog for when I worked on a blog entry. The logfile is ~/.gtimelog/timelog.txt . pt Short for “print today”, it prints an overview of how much time I spend on what today. Call it like pt week to get an overview of the whole week (and a couple of earlier weeks, in case I need that).

The tl command works best when you add tab completion. Add a ~/.gtimelog/tasks.txt file, which should have one word per line, each being a task you want to log with tl . Hook up the following into your bash completion:

_timelog() { local cur prev COMMAND_NAME='timelog' COMPREPLY=() # Word that is currently being expanded: cur=${COMP_WORDS[COMP_CWORD]} # Previous expanded word: prev=${COMP_WORDS[COMP_CWORD-1]} # We look for ~/.gtimelog/tasks.txt, which should have one word # per line, each being a project. CONFIGDIR=~/.gtimelog if test ! -d $CONFIGDIR; then return 0 fi PROJECTS="$(cat $CONFIGDIR/tasks.txt | grep -v \#)" COMPREPLY=( $(compgen -W '$PROJECTS' -- $cur ) ) } complete -F _timelog tl

Works quite well! But, if possible, use the official gtimelog with its gtk interface. Note that they work interchangably thanks to the power of plain text files :-)