Thursday, October 25, 2007

Neal's Lint: TextExpander

I've been asked several times about the prodigious amount of "lint" I have on my menu bar (those are the little application icons to the right, in what would be the task tray in Windows). So, I'm gonna tell everyone.

First up, TextExpander. This is a key macro utility. Think live templates for your entire operating system. You save whatever text you want to type under an abbreviation and TextExpander automagically expands it for you inline. For example, I type the words "No Fluff, Just Stuff" a lot, so I have a shortcut for it. I'm genetically incapable of spelling the word "Selenium", so I have another for that. I also have chunks of command-line goodies that I used to have as bash aliases, but I got tired of fighting the single-double quote war with bash. Now, I just type the abbreviation to get this:

svn st | grep '^\?' | tr '^\?' ' ' | sed 's/[ \t]*//' | sed 's/[ ]/\\ /g' | xargs svn add
What's even better is that you can determine where you want the cursor to end up by placing a magic marker there. For my Ruby on Rails talk, I need to create a database keyed to the city I'm in, so I use this TextExpander goodie, which leaves my cursor right before "_development".

/opt/local/bin/mysqladmin5 -u root create %|_development
What's more, you can create abbreviations for stuff like dates. Life's too short to be typing the bloody date all the time, so it looks like today is 2007-10-25.

TextExpander is a great example of a "$20-ware" Mac OS X utility (see, I just typed "Mac OS X" with an abbreviation). There are some others like this (like Typinator), but I prefer TextExpander.

2 comments:

Unknown said...

Using TextExpander for your shell commands is IMHO a bad idea. For instance if you log remotly into your machine your shortcuts won't work. Further I work with different OSes (Linux, Mac, FreeBSD...) and I just copy my shell enviroment to a new machine and have all my abbreviations at hand.

Btw.
svn st | grep '^\?' | awk '{ print $2 }'
is a little bit shorter :P

For the rest I fully agree: TextExpander is a really useful utility.

Neal Ford said...

Ah, but your version doesn't handle embedded spaces. But, last thing I want to do is get into a Bash-Fu argument!

You are dead-on accurate about not having those snippets on remote machines by default (unless you are using SSH) or, like me, you share your snippets files across machines. In that case, it's exactly like having the same bash aliases without having to fight with the stupid single-double quote thing. But, of course, there are other tangible benefits to having the same environment (not just aliases) across machines.