Timetrap: Simple Command-Line Time Tracking with Ruby

July 18, 2009

Who knows where the time goes?

That’s a question that I was asking myself a lot a few months ago. And the results of all that asking was a command line time tracker called Timetrap.

There’s a lot of good reason’s for tracking what you spend your time on (especially if you bill by the hour), but I was finding a lot of the time tracking tools out there to be kind of kludgy. What I really wanted was something that would let me easily track and edit time entries and get out of my way. It would be even better if I could use it on the command line, since that’s where I am most of the time when I’m working.

I got the idea for writing Timetrap from a cool little command-line time tracker called Timebook (written in Python by Trevor Caira.) It let’s you track your time through a command line utility named t. I loved simplicity of the interface, and how it lets you abbreviate any command, typing t d instead of t display.

$ t switch World Domination Plan
$ t in Research Volcano Islands
$ t out
$ t display
Timesheet World Domination Plan:
Day            Start      End        Duration   Notes
Mar 14, 2009   19:53:30 - 20:06:15   0:12:45    Research Volcano Islands
Total                                0:12:45

The problem was it wasn’t flexible enough. I’d forget to start it and want to type:

$ t in --at "5 minutes ago" Research Volcano Islands

I needed an easy way to edit an entry after the fact. I wanted:

$ t edit --id 45 --start "last Monday 10am" --end "last Monday 12pm" created 4000 novelty buttons

And I wanted to be able to easily export to a variety of formats (such as ical and csv,) and easily add additional export formats with a few lines of Ruby:

$ t display --format ical > my_ical_file.ics

All of the above commands work in Timetrap, which also has an archive command that moves your entries to a hidden sheet, where they’re out of the way.

I’ve been using it to track my own time for the last few months, and it’s working really well. I’ve been focusing more of my time on working, and less on tracking what I’m working on.

There’s still a few features I’m planning to add when I find the time (like an option that shows/exports your entries rounded to 15 minute intervals.) But I thought there might be some others out there that would find this useful. It’s available on github. Feel free to let me know about any bugs you find, or if you’re interested in contributing code.