Matthew Price

Printing TODO Comments With Ack

TODO Output

There are a lot of terminal commands floating around that will list the TODO comments in your source code, but I’ve always found their output format lacking. Last week I decided to come up with something better. It’s language agnostic and it organizes everything into vertical columns to make reading easier:

ack -i -o --sort-files '(TODO|FIX(ME)?|OPTIMIZE): (.*)' * --pager="perl -pe 's/:/\t/'"

Here’s a breakdown of the options we’re using, and a few others you might find useful:

Option Description
-follow Follow symlinks
-i Ignore the case of matches
-n Don’t search within subdirectories
-o Display only the matched text1
--pager Send the output to another program2
--sort-files Sort the outputted files in alphabetical order
  1. When combined with wildcard matching, this helps us discard any tabs or spaces that come before the comment.

  2. In this case we’re sending the output to Perl, which replaces the first colon it finds with a tab character so that the TODO comments line up perfectly.

Merry Christmas

Christmas Card 2013

Wishing you all a merry Christmas and a happy New Year.

Institutions will try to preserve the problem to which they are the solution.

Clay Shirky

We are put on this planet only once, and to limit ourselves to the familiar is a crime against our minds.

Roger Ebert