I’ve been wanting a script for a while now, that would pop a bunch of terminals, change to some useful directories, start services, and sit where I want them… oh, and be the size that I want them too… oh, and open up my app in TextMate too. I googled around for a while, but never really came up with much, so I decided to take some time this morning, and figure it out. As it turns out, Applescript it isn’t terribly complicated, and with a little bit of time spent reading the docs, I was able to bust this out. Check the link below for Apple’s official documentation:
So, I’ll start with how to run the thing, and then go into some details about configuring it for your particular setup. You should know though, that the script makes a few assumptions about your development environment:
- You’re on a Mac (duh)
- You’re gonna download the script (get it here)
- You use Quicksilver (if not, get it here, it’s free)
- You use TextMate (if not, get it here, there’s a free trial)
- You have a sane structure to your project directory, and keep them in ~/work (This is easily changed, if you wish)
- You like a terminal for your server, log, and console, and keep them all on the same display/desktop (again, you can change this)
Okay, with all of that out of the way, let’s get on with it. The way this baby works is simple. You invoke Quicksilver (usually ctrl + space) and hit . (the period key) to enter some text. Type out the FULL name of the folder of the app you want to start. Assuming you’re set up with the defaults above, your app called “codeFoo” would live in ~/work/codeFoo, and you would simply type codeFoo in the input field of quicksilver. Next you’ll hit tab to move to the action pane, and type dev or dev_r or something to that effect, to get Quicksilver to look up the script for you. (If you’re not already aware, quicksilver learns the stuff you use and like, and will eventually move that to the top of the list of actions, if it’s not already there. Just use the same string every time to get it.) Once you’ve got the script, hit return, and watch it go! It will fire up three shells for you, start a server, a console, tail the development log, and open your app in TextMate. Productivity bliss, I tell you!
So now that you’re frothing at the mouth to get started using this thing, you need to know how to install it. Again, simple. Just download the script, untar it, and stick it in ~/Library/Application Support/Quicksilver/Actions. If the Actions directory doesn’t exist yet, go ahead and create it now. I’ll wait… Done? Ok, sweet. Just restart Quicksilver (or rescan the catalog, but it seems that doesn’t always work) to pick up the changes, and you’re on your way!
Now, I know you’re anxious to get to work and all, and this script will work with the defaults, but you’ll likely want to do some customization of your own to make it fit your setup just right. To tweak it out, just open it up in the AppleScript Editor, and follow the instructions. You can control the placement of your terminals, change their sizes, change the directory it looks in for your rails apps, etc. If you want, you can even add some arguments to make your terminals different colors, but I didn’t include that in this release. (Just look at the dictionary for termial in the script editor) The default placement of the terminals assumes you are running dual displays, with the secondary to the left, running 1280×1024, and will drop all of your terminals there. If you don’t like that, or you don’t have a secondary display, you should either hit up craigslist, or change this before you use the script. (I haven’t tested it on just a single display to see where the terminals will go with the default settings.)
I had hoped to set this up so that you could navigate directly to the folder you wanted to act on, without having to type in the full name manually, but as of this writing, Quicksilver and AppleScript don’t get down like that, so the only thing we can access is the text you input. Hopefully, one day, in the not so distant future, we’ll have that capability. I’m also looking into what can be done with Spaces (the new, but somewhat sketchy multiple desktop feature in Leopard) via AppleScript, but for now, this stuff will all open on the same “desktop”, and I don’t know how to change it. So, for now, enjoy!