JOEHEWITT.COM

Quasi-daily thoughts. No cute taglines.

Sunday July 24

Workflows Part 3: Navigating Plain Text

As I've mentioned before, I spend an awful lot of time working in plain text. This text has lots of stuff in it that references other files, and I'd like to be able to treat those references almost as if they were hyperlinks in a web page.

If you read my previous "Workflows" post, you'll recall that I talked about how I paste images into my blog posts, using a syntax like this: [[image:image2.png]]. Just the ability to paste images alone is not enough, because I also need to actually see the image that I have pasted, and sometimes I want to delete it.

Being as lazy as I am, I don't have patience to go digging around in Finder or typing out paths on the console. I just want a single stroke interaction for visiting an image that is embedded in the text.

Luckily, I have Quicksilver.

My solution to this problem is simple. I put my cursor inside of the text [[image:image2.png]], hit Option-3, and up pops Quicksilver with the image selected:

With this system in place, I never have to wonder "Hmm, what is the full path of that file?". I just let my personal web server do the searching, and use Quicksilver to display the results. By the way, this works for more than just images embedded in text files. I can also jump to header files in a C/C++ #include or Python modules in an import statement, and I am always on the lookout for more.

Once Quicksilver has its hands on the image, I can do just about anything with it. If I just hit Enter, it will open the image using Preview. Let's say I want to delete it. I can just hit Tab T Enter and bam, it is in the trash. Quicksilver offers a plethora of other commands as well:

Also, if I want to see another image that I have recently pasted, I hit Down Arrow and I get a view of the directory that the image is in, from which I can select another image to apply a command to:

How does this all work? First, an Applescript grabs the line of text that my cursor is on along with the offset of the cursor. It relays that to my Python web server over XMLRPC. Inside the server it is parsed, and if the object intersecting the cursor references a file, that file's path is sent back to the AppleScript. The path is then handed to Quicksilver like so:

tell application "Quicksilver" to set selection to someFilePath

It took me a while to get in the habit of using Quicksilver, but now that I am fully invested, I must say that it is by far the best way to navigate the files on your computer. Without it, I feel lost every time I use Windows.

at
Posting your comment. Please Wait...