My did to help me remember what I did

This article was making the rounds this week: did.txt file. Lately, I’ve been having trouble remember what I did, so the timing of that post was perfect.

In the past, I’ve been able to do this in git like git reflog --since yesterday --decorate --author $(git whoami), but these days I’m in many Git repos and a lot of my work isn’t code, so the `did.txt` solution looked great. But following my slogan, “do the same thing you’ve already done, unless you can do it lazier”, I came up with an even lazier method. In my dotfiles, I have this bash function:

# Inspired by https://theptrk.com/2018/07/11/did-txt-file/
did () {
 mkdir -p ~/Documents/did
 if [ -n "$*" ]; then
   touch ~/Documents/did/"$*";
 fi
 find ~/Documents/did -type f -printf "%TY-%Tm-%Td %TH:%TM\t%P\n" | sort -nr | head -n 10
}

You use it like:

$ did Printed my TPS report
$ did Re-printed my TPS report with the new cover sheet

And you use the same command with no arguments to get what you did:

$ did
2018-07-18 10:59 Re-printed my TPS report with the new cover sheet
2018-07-18 10:27 Printed my TPS report

Shortcomings

Eventually, I’ll have to clean out my ~/Documents/did, but that’s just deleting old files. It’ll be fun to relive what I was doing. If it actually becomes a problem, it can be automated too.

A duplicate update erases the earlier entry. In real life, this won’t happen much. And if it does happen, you don’t want the duplicates anyways. I see this as a feature.

OSX users

find on OSX doesn’t have -printf, so you’ll need brew install findutils. I recommend just running it like brew install findutils --with-default-names so find just works the way you expect it to.

Leave a Reply

Your email address will not be published. Required fields are marked *