Real-world OpenMeta Plug-in Use

There are some pretty obvious uses for Quicksilver's OpenMeta File Tagging plug-in, like grouping files together that are flung far and wide across your disk. Here are some other things I'm using it for that really make life easier.

What do I need to work on?

I suspect a lot of people have a tag they assign to things that need their attention, such as "Active Project". A couple of Quicksilver triggers can make this even easier.

The first is

Current Document ⇥ Add Tags… ⇥ Active Project

The Current Document proxy object (from the User Interface plug-in) is really flexible. Of course it works in just about any document-based application, but it can also be used to get the current directory from a Terminal window1 or the current URL from a browser2.

So if you're working on a spreadsheet, or a script, or something in the Terminal and you don't want it to slip through the cracks later, just fire off the above trigger and get back to work.

Since right-arrowing into a tag lists all of the files with that tag assigned, the next trigger is

Active Project ⇥ Show Contents

This gives you quick access to any pending projects that need your attention.

One-off Catalog Entries

How many folders full of crap have you added to your catalog just to access one or two files that you use all the time? You may have also copied some of the default entries just to increase their scanning depth for the same reason. I had three or four custom entries like that, but not any more.

The OpenMeta plug-in includes a new type of catalog entry called "OpenMeta Tags". It works like the File & Folder Scanner by adding files to the top-level catalog, but instead of recursively scanning a path or a file's contents, it looks for one or more matching tags. (It must have been a handsome and brilliant fellow that thought to add this feature.)

So here's what I've done:

  1. Locate the one-off files you actually care about.
  2. Tag them with something like "Quicksilver Catalog".
  3. Add a custom catalog entry, choosing "OpenMeta Tags" from the pop-up menu.
  4. Put "Quicksilver Catalog" in the list of tags it checks for.
  5. Remove the File & Folder entries you were previously using to access these files.

This can trim a lot of noise out of your catalog, which should speed up searching. And once the entry is defined, you can quickly add more files to the catalog just by tagging them.

And of course, you can create as many entries as you want for other tags, like "Active Project".


  1. This requires the Terminal shipped with 10.7+ and it requires your shell to update the titlebar whenever the current working directory changes. This is part of the default bash profile on OS X, and can be made to work with zsh and other shells. 

  2. I mention the URL thing for completeness, and because it's cool, but unfortunately, you can't tag something unless it has a corresponding file on disk so don't go running your new trigger in Safari. 

Tagging in Quicksilver

There are two Quicksilver plug-ins that allow you to tag files: Spotlight and OpenMeta. What's the difference? Which one should you choose? The goal of this post is to answer the first question and help you answer the latter for yourself.

I didn't write either plug-in originally, but I've contributed a great deal to both.

Common Features

Both plug-ins allow you to select one or more files in Quicksilver, then add or remove one or more tags to those files. You can also show existing tags for the selected file(s).

All the tags you use will (eventually) be added to Quicksilver's catalog by default. You can search for a tag in Quicksilver, then hit → or / to show all files matching that tag.

Tags can also be used when searching via the normal OS X Spotlight interface.

Both plug-ins provide a new type of catalog entry that can be used to add files to the catalog based on assigned tags1.

Spotlight

When you use the Spotlight plug-in, tags are stored as text in the file's Spotlight Comments field. The advantage is that you can view and edit tags via Finder's "Get Info" panel, in addition to using Quicksilver.

To distinguish tags from normal words in the comments, tags will be prefixed with a character of your choice. (The default is #. Previous versions of the plug-in used @.) When adding tags to the catalog, the prefix is removed and only the tag's name is shown (for cosmetic reasons).

Tags are separated by spaces in the comments, so unfortunately, they can't contain spaces.

The actions that manipulate tags should correctly preserve other (non-tag) text in the comments, and the plug-in's "Set Comment…" action should correctly preserve tags.

OpenMeta

The OpenMeta plug-in stores tags in extended attributes. The advantage is that tags aren't mixed with any other type of metadata, so they don't require any special prefix and they won't interfere with other data like comments. This means they're "hidden" from the standard interfaces like Finder2, but there are several third party applications that work with OpenMeta tags. You can also use the openmeta command-line tool, but it's not required as it was with previous versions of the plug-in.

Since tags are stored in a dedicated attribute, they can contain spaces and just about anything else. The only real limitation is that, when entering multiple tags by hand in Quicksilver, it separates them with comma, so you can't include a comma in the tag via Quicksilver. I assume you could get around this using another interface if it's really important to you.

In Quicksilver, when you right-arrow into an OpenMeta tag, in addition to a list of files matching that tag, you will see other tags assigned to those files. If you select one of those tags and right-arrow again, you'll be shown a list of all files matching both tags, and any additional tags they have. You can repeat this for any number of tags. This is a powerful feature3 and a quick way to narrow down a long list of tagged files.

One last advantage that the OpenMeta plug-in offers is quicker access to new tags. Whenever you change the tags for a file in any way, the plug-in rescans your system to see if there are any new tags and adds them to the catalog almost immediately. Tags assigned outside of Quicksilver will not be detected until the next scheduled catalog scan.

Summary

If you just want something basic that doesn't rely on any third-party voodoo and lets you see tags outside Quicksilver in a more obvious way, use the Spotlight plug-in for tagging.

If you want something more powerful and dedicated to the task, or if you've already started tagging files using other OpenMeta-compatible applications, the OpenMeta plug-in is the best choice.


  1. The Spotlight catalog source is actually more general purpose and not meant for tags specifically. So to do this is far less straightforward, as it requires you to type complicated search syntax by hand, but it is possible. 

  2. OpenMeta tags can be used in any Spotlight search, including those in Finder. You just can't view and manipulate tags. 

  3. The Yojimbo plug-in also treats tags this way. There's no technical reason why the Spotlight plug-in couldn't provide this feature, but it hasn't been implemented as of this post. 

Display Useful Timestamps on GitHub

Relative dates are fashionable, but they hide important information. There doesn’t seem to be a way to disable them on GitHub, but I found a decent work-around.

This is specific to Safari. First, you need the wonderful User CSS Safari extension.

Now, create a new User CSS called “Absolute Timestamps” or whatever. I left the URL Includes set to *, so if any sites other than GitHub use the same JavaScript, they’ll be affected too (which is what I want).

Define something like this for the style:

.js-relative-date:before {
  content: attr(title) " (";
}
.js-relative-date:after {
  content: ")";
}

Now, you’ll see something useful like “2012-09-18 08:09:36 (2 months ago)” in place of the relative date alone. The content you add becomes part of the element, so unfortunately, you can’t hide the relative date completely.

I assume you could also write a Safari extension that used JavaScript to change the class js-relative-date to relative-dates-suck, but I don’t want to deal with JavaScript so I haven’t tried that approach.

virtualenv, virtualenvwrapper, and TextMate

Since discovering virtualenvwrapper, I now want to use a separate environment for almost everything. I set one up to go through a Pyramid tutorial and thought it would be nice if TextMate (2 alpha) could run the copy of Python from the isolated environment when I hit ⌘R in application.py, and as a bonus, let me know about this by displaying the name of the environment in the title bar. This turns out to be pretty easy.

First, make sure TextMate knows about your WORKON_HOME variable somehow. There are a couple of ways to do this, but I just set it up in the application's preferences under "Variables".

Next, put this in $WORKON_HOME/postmkproject:

1
2
3
4
5
6
7
8
#!/bin/zsh
# This hook is run after a new project is activated.
export VIRTUAL_ENV_SHORT=`basename "$VIRTUAL_ENV"`
export TMPROPERTIES=$PROJECT_HOME/$VIRTUAL_ENV_SHORT/.tm_properties
echo "Configuring TextMate to use this virtualenv for this project"
echo "TM_PYTHON = \"\$WORKON_HOME/$VIRTUAL_ENV_SHORT/bin/python\"" >> $TMPROPERTIES
echo "[ *.py ]" >> $TMPROPERTIES
echo "windowTitle = \"\$TM_DISPLAYNAME ($VIRTUAL_ENV_SHORT)\"" >> $TMPROPERTIES

Now, when you create a project, its .tm_properties file should be set up automatically.

% mkproject pyramid_humans
New python executable in pyramid_humans/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /Users/rob/.virtualenvs/pyramid_humans/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/rob/.virtualenvs/pyramid_humans/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/rob/.virtualenvs/pyramid_humans/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/rob/.virtualenvs/pyramid_humans/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/rob/.virtualenvs/pyramid_humans/bin/get_env_details
Creating /Users/rob/Coding/Python/pyramid_humans
Setting project for pyramid_humans to /Users/rob/Coding/Python/pyramid_humans
Configuring TextMate to use this virtualenv for this project

% cat .tm_properties
TM_PYTHON = "$WORKON_HOME/pyramid_humans/bin/python"
[ *.py ]
windowTitle = "$TM_DISPLAYNAME (pyramid_humans)"

The obvious drawback is that this happens for every project, whether you plan to use it with TextMate or not, but it's a very small, hidden file and I don't expect to have many projects like that anyway.

The proper way to impliment this is probably as a virtualenvwrapper template. That would allow you to get this only when you wanted it by running something like mkproject -t textmate pyramid_humans, but I haven't figured out how to create a template. It seems insanely complicated for something this small.

Work Around Safari 6's Smart Search Field

I don't use Google Chrome for a number of reasons, but by far the most annoying thing is the combined address/search text field. When I type something like "youtube", here's what I expect to happen:

  1. Check DNS for youtube (in my local domain)
  2. If not found, check DNS for www.youtube.com
  3. If not found, show me an error

Not in Chrome. Chrome assumes you must have wanted to search for "youtube", whether it's in DNS or not. But then, what do you expect when a search company makes a web browser?

Unfortunately, as of version 6, this pantywaist crap has made its way into Safari. I have no idea why this was necessary. I had no problem searching the web yesterday, so I've gained nothing while I've lost something quite useful.

The Work-around

Using Quicksilver's Web Search plug-in, you can recreate step 2 above (which is the most common use case for me). For those that aren't familiar, Quicksilver lets you add something like https://duckduckgo.com/?q=*** to your catalog and then use that to search for text. The *** will be replaced with the text you supply. It was meant to be used for search terms, but since all it's doing is replacing one string with another, it's actually more versatile.

So, what I've done is created a new custom "web search" in Quicksilver with http://www.***.com/ as its address and called it "Domain". To use it, I can either

  1. Invoke Quicksilver
  2. Enter a term like "qsapp" in text-entry mode
  3. Select the "Find With…" action
  4. Select the "Domain" web search

or

  1. Invoke Quicksilver
  2. Select the "Domain" web search
  3. Select the "Search For…" action (which will be the default)
  4. Enter a term like "qsapp"

The result will be http://www.qsapp.com/, open in my default browser.

I'm still irritated that entering "projects" will search for that word, even though it's a perfectly valid name for a server in my domain, but prefixing the name with http:// appears to get around that. You could make a web search for that too, I suppose, but it's not worth it in my case.

Update: 13 October 2012, 10:11pm (America/Indianapolis)

You can induce Safari 6 to perform the old behavior by appending /. This works for domains (cnn/ becomes http://www.cnn.com/) and for hostnames (projects/ becomes http://projects/ if that host exists in your domain).

Want more?

Check out the archives.