A lot of times I just want to record something. This should be one of those things computers are good at. Turns out this is a bit harder than it seems: many editors make you name a file to save it.

One easy-sounding way to record something is:

  1. open up a text editor
  2. mash the keyboard until the thought is out of your head and into the text editor
  3. (hard part starts) what do we name that file?
  4. where do we put that file?
  5. do we remember to save that file, given the difficulty of (3) & (4)?

I think picking names too early is at best a minor annoyance, and at worst a pretty major distraction.

  • You have to use that early name to open that file later to make changes.
  • The process of assigning a name and referencing it repeatedly puts a damper on changing the idea "too far" from the original idea and original name.
  • If that name is utilized in a URL or shared with anyone or (worst of all!) gets linked from other documents, changing it means changing everywhere it might be linked from. This problem is hopeless if we permit our friends and coworkers to retain private documents/bookmarks/etc. Even considering shared workspaces, frequently it isn't even possible to enumerate such places. (I'm looking at you, Google Docs.)

One alternative is:

cat >> ~/to_file/$(uuidgen) << EOF
my super clever thought

This is slightly unsatisfying, too: MacOS tracks update timestamp, not creation timestamp, by default. So we maybe want a separate "meta" file here, if the creation timestamps are important. But we can tackle it with either discipline (never update!) or a small bit of extra complexity, like

date +"%s" > ${U}.created_at
cat >> ${U} << EOF
my even more clever thought

With even that tiny bit of infrastructure in place, we can generate a timestamped log of "recordings" about whatever is useful to you!

The access pattern is kinda interesting here. Obviously, we don't want to -- and won't, or at least shouldn't -- remember the raw UUIDs. So we need to search, instead. We can use something like ag:

~/to_file ➜ ag clever
1:my even more clever thought

1:my super clever thought

Why bother with uuidgen?

  1. I have built some very small systems on similar ideas but with much shorter "token generation" schemes; the problem here is eventually they conflict, and you either lose data (perhaps unknowingly), concatenate entries (perhaps unknowingly), or need to implement an existence check.
  2. In the case of a shared folder (like Dropbox), the existence check can't check whether records already exist on a "replica" (ie your personal laptop) that hasn't been synced yet.
  3. It's built into MacOS, so there's no custom token generation code to write.

This is conceptually kinda similar to the technique of Write-ahead logging: The ~/to_file directory functions as our "log" (of "thoughts" or "recordings" or whatever), which is to be reconciled later by moving the file into a more appropriate place.