TextMate projects: faking metadata

Wrote this long-winded post to the TextMate list, so I thought I’d repurpose it here. Just quick tips on adding metadata to your text files and—because I’m a dull and repetitive scold—using controlled vocabularies to keep your stuff searchable.

This is a just a little tip for folks who run their life in TextMate (as I have begun to).

I have a single TextMate project in which I keep and maintain all my todo lists, project files, reference notes, etc. I’m a bit of a “Getting Things Done” nerd, so I admit to spending a lot of time fiddling around with lists. :)

I’ve evolved a standard header that I use for most of my txt documents that is similar to this example from my “Next Actions” (aka “to-do”) list

Nothing too spectacular, but the little metadata line has really started to come in handy; I now can do a “Find in Project” on all my files and pick up any relevant hits—even when the term is not expressly mentioned in a given line of text. It’s a great way to bubble up hidden content—even when it’s many layers deep in the Finder.

The other, related tip, which I’ve mentioned before on my site is to try and standardize your vocabulary for TODOs or anything else you’ll want to locate in a pile. I try to begin all of my TODOs with a verb followed by a fairly detailed phrase. E.g.

Buy propane at Albertson's
Google the best way to run DynDNS on a Linksys; how to retain links?
Email John about his site updates for Friday

This becomes really useful for GREPing a list of related topics and even generating a new one.

TextMate has really made me want to hone my modest shell skills to learn what it can do, because it seems pretty limitless. I’m just starting to install a few commands that will concatenate related files and generate these kinds of searches on the fly. I’d love to hear how other folks are using TM and the shell for tasks outside development, web design, etc. There’s an awful of of power under that hood.

And, per that last bit, I do encourage fellow TextMate nerds to share their productivity tips in comments here.

re grep: one interesting thing you can do, especially once you've started putting in "fake" (ie. unpretentious :-) metadata, is combine find, grep, and xargs to do more advanced searches; for a simple example,

would look in every file in dir that contains "chinese food", cambridge, and beef, and print the lines mentioning beef. Breaking it down, find dir walks that directory, -type f says "only deal with files (not links, sockets, or directories)", and given nothing else, just prints the names; xargs command says "take every word on input and run command on it, batching them up as much as practical"; grep -l word files says "look for word in each of files and if you find it, just print out the file name"... and now that we have a list of filenames again, we can start right back in with xargs. The last one in the chain uses -n, instead of -l, to print the line number and filename along with the matched text, instead of only the filename. You might use grep -C for the last step to get "Context" around the hit.

The one thing to watch out for is that unlike google, this can be slow, because it looks at each file each time - but Moore's Law has moved many practical values of "slow" into "fast enough for me" :-)

43 Folders is powered by Drupal, which rules. The site was designed and made wonderful by the astounding Chris Glass. Ben Durbin is the sine qua non and our personal consigliere. 43f’s web hosting is sponsored by A2.