Archive for July, 2007

TextMate: How You Can Edit Most Everything in the World

I want to write an entry for my blog but boy howdy I can’t stand typing a bunch of text into a text field on a web page! Whatever can I do?

You can use TextMate, that’s what you can do.

tmicon

Wait, I thought you were going to say, “Use ecto.” Isn’t TextMate just a text editor?

Saying that TextMate is a text editor is like saying that the oceans are damp, or that the sun is slightly luminous. Sure, you’re right… but only as far as you go. And you don’t go very far. Magic Dave Ball to the rescue!

Gratuitous Background

If you want a history of TextMate, I refer you to two sources: TextMate’s Wikipedia page and a pretty excellent book by the Pragmatic Progammers about TextMate. Any history I can give would only be stolen from these two sources.

Suffice it to say that TextMate has won numerous awards and each revision continues to improve upon the basic ideas of simplicity and excellence, the pillars of which bolster the roof of awesomeness. Ah, metaphor.

We’ll also be discussing Markdown. I’ll let John Gruber explain:

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).

What all that means is that you get to write regular ol’ text, with some formatting conventions, and this nifty tool will transform it into HTML. Because, really, no one likes writing HTML; anyone who says otherwise is concerned for his/her job security.

I Thought This Was About Blogging

You’re right, of course, I was going to write about blogging.

The first thing that happens when I conceive of a blog entry is that I must, immediately, write down that idea somewhere. My brain is a sieve, and were it not for the more persistent forms of memory handed down to us by our silicon masters I would be reduced to a gibbering gibbon, scratching my red butt as I wondered where to fling my next batch of poo. That’s where TextMate comes in. TextMate help me fling my poo at my blog where it can be shared with the rest of the world. Excellent.

So fire up TextMate. If you need to download it, go get TextMate here. No more installation instructions, we’re all adults here.

TextMate is filled to the brim with loads of helpful bundles. Among these is the “Blogging” bundle. Yes, that’s right, the one we’ll be discussing at length today. Very good. Have a donut.

In Textmate, go to File > New from Template > Blogging > Blog Post (Markdown). You’ll notice three other choices in that last menu: Textile, HTML, and Text. Textile is like Markdown but, I feel, not quite as readable in raw text form (sorry, Dean!). We all know about HTML (job security), and Text is — well, Text is Text. We’ll stick with Markdown for now.

And voilà! A brand new TextMate window is now open with an empty blog post.

Is Your Blog Ready?

Ah, yes, of course. No, it isn’t.

One geeky-cool thing about TextMate is that some of its configuration is available as, well, text. In TextMate, go to Bundles > Blogging > Setup Blogs. A window should open up that looks a bit like this:

tmblogsetup1

Check it out: That looks like an entry named “magicdaveball” with a funny looking URL after it. The format of the URL is very, very easy:

http://<username>@<address.of.your.blog>/<path.to.endpoint>

“username” seems straightforward (usually “admin” on a Wordpress blog unless you’re all multi-author in which case bully for you for having friends). “address.of.your.blog” is also pretty straightforward.

What the heck is that “path.to.endpoint” nonsense? Ah, well, that’s the path to your (get ready for it) XML remote procedure call endpoint. Y’know, the part of your blog software on the server that is easily susceptible to SQL injection attacks (bad!) and also handily lets you post to your blog with desktop clients (good!). According to the TextMate Blogging bundle’s own help file, here are the likely places for the XMLRPC endpoint on your blog:

Movable Type http://myusername@mydomain.com/mt/mt-xmlrpc.cgi#1
WordPress    http://myusername@mydomain.com/blog/xmlrpc.php
Typo         http://myusername@mydomain.com/backend/xmlrpc

The usually helpful help files are lying, just a little bit, since the location of your endpoint also depends on where you installed your blog. Magic Dave Ball’s blog isn’t in a “blog” subdirectory, for instance, it’s at the root. So my XMLRPC URL is:

http://admin@www.magicdaveball.com/xmlrpc.php

That was terribly easy. Yay us. Once you’ve made the necessary changes just hit ⌘-S (Save).

Let’s Test This Whole Setup Thing

We need to make sure this whole complicated process works. Make sure that your blog has at least one published post. This is key.

Go to Bundles > Blogging > Fetch Post. If you’ve defined more than one blog (how trusting!) you will now see that TextMate is helpfully displaying the names you gave your blogs back to you. How nice of it. You won’t see this if you only configured one blog; TextMate will immediately try to fetch the posts.

You should be challenged with a prompt for your password. Go ahead and type that bad boy in and hit Return (or Enter, sheesh).

If you’ve done these three things:

  1. Set up the blog with the correct username, address, and endpoint.
  2. Have at least one published post on that selfsame blog.
  3. Typed in the correct password for that blog.

…you should see a selection box allowing you to pick a post to look at! Neato!

If instead you see something like this:

tmerrornotfound

Then something Bad has happened with one of your three steps, above. Check carefully. We’ll all wait until you’ve fixed things. You can do it. The Magic Dave Ball believes in you!

Once that’s all done and taken care of, we’re on our way.

I’m On My Way

I like to ruminate at length upon my words. I like the essence of blog to steep within my text. I don’t like publishing poo. So I’m excited that we’re finally at the poo-refinement phase of our operation here.

In that new blog entry window you opened up a few steps back (you have been following along, yes?) you should see something like this:

Title: untitled

Main entry text

(funny scissor-looking-thing line)

Main entry continued

Title seems fairly self-explanatory. Put something clever there, something diggable: “Top Ten Blog Poo Consistencies”, “Fifteen Worst Computing Mistakes of All Time”. Yeah, there ya go.

But what about those other three lines? “Main entry continued?” And what place do little scissor-looking-things have in a text editor? What the heck?!

Take a deep breath. Ever seen the fancy, “Click here to read more…” links that some blogs have? That’s what that funny scissor-looking-thing-line is: It’s the cutoff point in your entry. Now the scissors seem kind of cute, don’t they?

Try this for me. Highlight the entire line of funny scissor-looking-things and delete them. Go ahead, get rid of ‘em.

Now find a blank line and type the word “cut” and then hit the TAB key.

Whoosh! You made your own line of scissor-looking-things! What the heck?

Here a Snip, There a Snip…

One of the most powerful concepts in TextMate is that of “Snippets”. Every bundle in TextMate has some. The Blogging package, being a TextMate bundle, has lots of blogging-related ones.

Try this: Go to some other blank line, type the word “keyw” and then hit the TAB key.

Whoosh! You made the text “Keywords: ” appear! Say, doesn’t your blog do something with keywords? Couldn’t you, say, put that near the top of this blog entry and further define some metadata about your blog entry besides the words themselves? Whoa!

Let’s pull back from the precipice a bit and just concentrate on getting a post up.

Fence Building

Get it? “Get a post up”?

I slay me.

Anyway, type in some text into your new blog entry like so:

tmblogtext

(And how did I generate that great “Lorem ipsum” stuff? Using the “lorem” snippet in TextMate… try it!)

Once you’ve got some text, let’s preview it. Sure, you could use the menu and go to Bundles > Blogging > Preview… or you could be more awesome and type the unlikely key combination of CTRL-ALT-COMMAND-P (for you Mac-savvy types, that’s ⌃-⌥-⌘-P) to see your lovely blog post.

Hmm. Not so lovely.

Wait a minute! What happened to Markdown, anyway?

Aha! Go to your blog entry and paste in the following:

Heading The First
=================

Blah blah blah...

Subheading 1
------------

*Italic blah blah blah...*

Subheading 2
------------

**Bold blah blah blah...**

Now preview it. Whoa! Look at how nicely formatted it is! Close the preview window and look at the text you pasted in. No, really, look at it.

Did you look? Did you really? Look again.

Okay, now that you’ve looked at it… what did you notice? Look at how the headings have underlines. Look how the italic text and the bold text are surrounded by asterisks… I mean, c’mon: Who doesn’t do that when IMing their friends? Or emailing them (you old fogies)?

TextMate can even help you here. Type this into your blog entry window:

Here Is My Heading
=<TAB>

Of course, instead of typing <TAB> try pressing the Tab key.

Shazam! TextMate underlines the entire header with equals signs, which is Markdown for, “Surround this with an H1 tag.”

Try typing something between a pair of asterisks. You’ll notice that TextMate formats the text in the window to remind you that you’re bolding or italicizing your text. Not bad, eh? Try and do that in Notepad. This works with underscore characters (_) and asterisks (*). Either one works as well as the other and can be interchanged (but not used together!). One asterisk/underscore set around a phrase (*here is a phrase*) makes the phrase italic. Two asterisks/underscores set around a phrase (**here is another phrase**) make the phrase bold.

Okay, so finally we’re about to put your post up on your blog. Are you excited? You shouldn’t be, because all you have to do is type ⌃-⌘-P or use the wimpy Bundles > Blogging > Post to Blog menu item. TextMate should think for a bit, send some bits up the tubes, and then attempt to display your post in your default web browser!

Did that not happen for you? Were you able to fetch a post earlier? Go back and try to get that working first, as that step is rather crucial to posting to your blog.

Wait a minute, why didn’t it ask me for my password?

Ah, I’m glad you are just as security-minded as I am. Here at the Magic Dave Ball, I’m always worried about security. Constantly. Fervently. Waitaminute, where’s my tinfoil hat?!

Your password is getting stored in a keychain. If you’re adventurous and feel like messing with Keychain Access or with the security program from a terminal, you’ll find an entry that looks an awful lot like your blog site. You can change the password from Keychain Access through (strangely enough) the Edit menu.

And we’re done!

Things To Remember

TextMate is fantastically powerful. Markdown is usually pretty simple. Most blogs are mind-numbingly dull. Be a part of the solution, not the problem.

At any rate, remember these simple points:

  1. Is your blog set up? If not, in TextMate, Bundles > Blogging > Setup Blogs will do the trick.
  2. Can you fetch posts? Don’t be fooled by TextMate’s lies when it can’t find any posts… unless you don’t have any published posts.
  3. Type ⌃-H for Markdown help at any time. TextMate context sensitive help really can, if you let it.

Poke around in TextMate’s bundles. There’s some pretty awesome stuff in there that we might even cover in a future entry! Neat.

In Summary

Look at you! Blogging from a super-powerful text editor! You could almost be mistaken for a Unix geek if only you would grow a neck-beard, or have an opinion about microkernels and SMP (and be willing to express them at great length).

For a pretty visual representation of the whole frickin’ process, check out this movie by Mr. Macromate himself.

As always, I love feedback. Was this too long? Spot any errors? Any part confusing? Does any bit need more wit? Let me know!

Give use a shake next time as we cover… links!

Administrivia

The contact page is now up! I’ve also done away with that annoying “Click here…” link that navigates to a place partway down the post page; frankly, that was super annoying for me and I don’t even read my own blog.

‘Cuz, y’know, I don’t have to. I write the darn stuff.

Quicksilver: How You Can Bend Reality With Your Mind

That silly Finder, in Mac OS X, is so annoying. Isn’t there any way that I can skip using it and launch my applications directly? Perhaps using some good ol’ keyboard interface, instead?

Magic Dave Ball to the rescue!

There are many solutions to this common problem, but my favorite, by far, is Quicksilver.

The easiest way to get an idea of what Quicksilver can do for you is to start by using it as an application launcher… Become skilled enough at Quicksilver and you can say good-bye to the Finder entirely!

Gratuitous Background

“Quicksilver” is an old timey word for the element mercury which, at room temperature, is a liquid metal — transcending the barrier between solid and liquid. Ancient alchemists believed it to transcend the barrier between life and death.

Mercury is also, of course, the Roman god of tricksters, thieves, and trade (known in his earlier, Greek aspect as Hermes). Mercury’s trickster role informs some occult traditions as well… His duty as the Roman pantheon’s psychopomp no doubt lending itself nicely to that idea.

Yes, this application is that good. Really. This application launching stuff is nothing compared to what you’ll be doing with Quicksilver later. Trust me.

Install Quicksilver

Installing Quicksilver is easy as can be:

  1. Head over to the Quicksilver homepage and click on the “Download” link in the center of the page.
  2. After the DMG has downloaded, double-click it so it mounts, and then…
  3. Drag the now visible Quicksilver application to your Applications folder.

Oh how I spoil you, faithful reader. You are so lucky to be getting install instructions. Next time you won’t be so lucky.

Using The Mystic Portal

Quicksilver’s magic begins with its own invocation: Out of the box, that’s Ctrl-Space. I prefer ⌘-Space myself… but there’s no accounting for taste. If you’ve got Quicksilver running, go ahead and do that now.

If you’ve been following along (and I know you have!) then you should see the interface above. Go ahead and type some stuff in there. Just a few characters. Maybe “gar”. Do you see GarageBand as the first choice in the pop-up box that appears?

Hit Return (or Enter if you’re fussy). Abracadabra! You’ve launched GarageBand! (Why not edit a cool song while you’re at it?)

Try this whole process again. Invoke Quicksilver, type “gar” (and watch GarageBand show up)… but instead of hitting Return (or Enter), hit Tab. This will move the focus to the next window. Behold! What other things can you do to GarageBand besides open it? Hitting the down arrow at any time in a Quicksilver window will reveal more choices. Find out! Have some fun! Explore! By pressing Return (yes, yes, or Enter) you can select the action to perform on GarageBand.

If, at this point, you have accidentally run “Move to Trash…” on GarageBand… well, I have pity for you. Go root around in your Trash.

Try this out a few times with some other applications. Feel free to explore all the other choices that may be popping up in Quicksilver in the first pane… They’re not all applications.

Also Makes Julienne Fries

Have you noticed how your documents are showing up in that first Quicksilver tab? Y’know, maybe that PDF you were reading in Preview… or that ReadMe.txt that came with that shareware you downloaded?

Yup, Quicksilver lets you get at those, too. And they work just like applications do: Invoke Quicksilver, find the document you want, verify that the action in the second panel is “Open”, and press Return (that Enter joke is getting old… I’ll stop, I swear)… and voilà! Instant document-opening!

Notice a pattern here? A disturbing trend? I’ll give you a sec.

No, seriously, think about it. Sheesh.

Okay, okay, I’ll spill: Quicksilver is finding your stuff. It’s searching your drive, finding things, them making them available by name. First your applications… now your documents. This is all configurable in Quicksilver’s truly massive preference pane. Be careful in there, though: There be dragons.

What else could Quicksilver make findable in a few keystrokes? Hmm!

Things To Remember

At the heart of Quicksilver are these simple steps.

  1. Choose subject.
  2. Choose action.
  3. Choose modifier (sometimes).

We’ve covered some of what you can do in steps 1 and 2… we haven’t come across any actions that are complex enough to warrant heading in to step 3.

You’ll be sure and experiment, though, right? Play around? See what else is in the dark corners of Quicksilver?

I just knew you would.

In Summary

So, hey, check that action out! Without even going to the Finder, you’ve opened an application. That was really fast, too — faster than opening a new Finder window, going to the Applications folder, scrolling down until you found Garage Band, double-clicking it… blah blah blah blah blah, GUIs are so last century.

Wait, GUIs are last century but text-based interfaces are “magical”?

Shut up, you.

Check out all of my Quicksilver del.icio.us links for more (way more) information about this truly awesome program.

Tune in next time when we cover… text!

Got any feedback? Please leave me some comments! I read it all!

First Post!

The site is finally up and it’s time to rock and roll… in a geeky sense, of course.

I might spend some more time fiddling with the layout but now it’s time for the tough part: Writing up actual entries on all the digital stuff I’ve found. I can’t guarantee that all of it will be useful (this is the web, after all) but I hope that it will at least be interesting.

I can’t wait to get started!