FREN

#FF00AA


28 apr. 2007

Upload Using Transmit

@apple@

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.)

Want to know when I post new content to my blog? It's a simple as registering for free to an RSS aggregator (Feedly, NewsBlur, Inoreader, …) and adding www.ff00aa.com to your feeds (or www.garoo.net if you want to subscribe to all my topics). We don't need newsletters, and we don't need Twitter; RSS still exists.

Legal information: This blog is hosted par OVH, 2 rue Kellermann, 59100 Roubaix, France, www.ovhcloud.com.

Personal data about this blog's readers are not used nor transmitted to third-parties. Comment authors can request their deletion by e-mail.

All contents © the author or quoted under fair use.