My name is Cédric Bozzi, I make apps and websites, and this is my tech blog — you’ll find news commentary here, from a very opinionated Mac-head.
Il y a une version française ici, but most of this blog’s contents are extracted from my Twitter feed, and hence only available in one language (which varies randomly).
While I’m giving workflow optimization tricks for webmasters, I guess I might as well explain the most important one of all: editing a local copy of my website in TextWrangler, and uploading it to the remote server by pressing just a single keyboard shortcut.
I already alluded to it a couple of times, but I wanted to wait until I had a camcorder or decent webcam to do a screencast plus video and show how efficient it is; I just realized I could just describe it to you now, and make that video whenever.
So, here’s how it goes: I open a file in, say, ~/WWW/ff00aa, modify it, and press Cmd-& (that’s Cmd-1 on an azerty keyboard); voilà, the file is saved and uploaded and all I have to do now is Cmd-Tab to Safari and hit Cmd-R to reload.
First step: the keyboard shortcut. Open TextWrangler; go to the Scripts menu (that’s the little scroll icon) and choose “Open Scripts Folder.” That’s where you have to put the “Upload Using Transmit” script — you can just download and unzip it, or create it yourself with these contents:
set fileName to ""
tell application "TextWrangler"
save document 1 of window 1
set fileName to (file of document 1 of window 1)
end tell
ignoring application responses
tell application "Transmit"
open fileName
end tell
end ignoring
Now, go to Window / Palettes / Scripts and use the palette to set a hotkey for your script. Make it simple — you’re going to use it a lot.
(If you’re using BBEdit, the setup is exactly the same but you have to modify the script to say “BBEdit” instead of “TextWrangler.” If you’re using TextMate, open the Bundle Editor and use this screenshot as a reference — the command is open -a Transmit $TM FILEPATH.)
Now, onto the real cool part (I feel like I’ve described that before, but can’t find anything in my archives — weird): how is Transmit going to know what to do with the file you just edited? That’s terribly simple.
Here’s what the definition of my #FF00AA favorite looks like in Transmit (there’s no password because I use FTP over ssh with a passphrase-less key — I finally ramped up security when I opened a wifi access point for my MacBook — but that’s irrelevant):
The magic comes from the “Use DockSend” checkbox, and matching “Local Path” (where the local copy of your website resides) with “Remote Path” (where the files are on your server). Now, whenever you drag a local file to the Transmit icon in the dock (or in the Applications folder — or if you run Transmit on a file, as we do in the AppleScript above), it looks for a favorite whose local path matches that of your file.
Let’s say I’m sending ~/WWW/ff00aa/WWW/_php/_.php to Transmit (by pressing Cmd-& in TextWrangler after modifying it); Transmit will look through its favorites, find that the #FF00AA favorite has ~/WWW/ff00aa/WWW as a local path and /home/ff00aa/www as a remote path, and automatically upload the file to its rightful place of /home/ff00aa/www/_php/_.php. All of which, just by pressing a hotkey — and it also works by dragging and dropping files and folders (the images you just exported from Photoshop, for instance) onto Transmit’s icon.
Just make sure you have Growl installed, and maybe enable the Transmit confirmation sound, so that you know when your file is done uploading without having to switch to the progress window.
And… that’s why I love the Mac. (For the record, I worked the same way in Windows. Only I had to program my own FTP mini-client for that. You can try it, it works — but configuration is done by editing two XML files, and the FTP library I used displays an error message every so often.)
2001 01 02 03 04 05 06 07 08 09 10 11 12
2002 01 02 03 04 05 06 07 08 09 10 11 12
2003 01 02 03 04 05 06 07 08 09 10 11 12
2004 01 02 03 04 05 06 07 08 09 10 11 12
2005 01 02 03 04 05 06 07 08 09 10 11 12
2006 01 02 03 04 05 06 07 08 09 10 11 12
2007 01 02 03 04 05 06 07 08 09 10 11 12
2008 01 02 03 04 05 06 07 08 09 10 11 12
2009 01 02 03 04 05 06 07 08 09 10 11 12
2010 01 02 03 04 05 06 07 08 09 10 11 12