1 minute read

A really simple “todo” list command line tool.

I work in text files nearly 100% of the time. One of the many things this lets me do is drop “todo” items into comments wherever I am. Most often these are relevant to the point in the file that I’m working, but generally the goal is to get the item out of my mind and into writing as quickly as possible without breaking my flow in the current project. While I’m working you see a ton of comments like this:

# TODO: python style todo comment
// TODO: stata style todo comment 
% TODO: latex style todo comment 

You get the point. It’s nothing fancy, just a comment with TODO: in it. This isn’t a system though, it really just makes a mess, all of these todo items strewn about my projects!

But, it’s really simple to make this into something much more useful. To find all of the TODO: items in your project just head to the root directory of the project and type:

grep -nr "TODO:" .  

And you’ll get a stdout something like this:

./2021-01-08-todo_list.md:15:# TODO: python style todo comment
./2021-01-08-todo_list.md:16:// TODO: stata style todo comment 
./2021-01-08-todo_list.md:17:% TODO: latex style todo comment 

It will be a list of all the files and line numbers where these TODO: items occur (-n give you the line number), in the current directory and all the subdirectories (-r makes this recursive). To make this into something like a cli tool I just dropped the following line into my .zshrc:

alias todo='grep -nr "TODO:" . > todo.txt;cat todo.txt'

And as I work my way through my projects I just type todo in my terminal to capture a list of all the unfinished items I’m leaving behind. At the end of any session I’ll just check for anything that should get clarified or pulled out to other projects or notes, and then I leave myself a little list of what I need to tidy up when I come back.