23 October 2005

Remember when I explained that any self-respecting (or at least Garoo-respected) webmaster must keep a copy of his sites on his hard disk and edit his files there (and test them locally, if possible) before sending them onto the production server?

The problem is, you end up maintaining two mirrors of the same sites, and every time you want to change a file you have to open the FTP client, find the local copy, find the remote copy, and switch from text editor to FTP with every change in order to upload the file again. So annoying I eventually programmed my own program to automatically upload files to the right place on the server just by pressing a shortcut key in the text editor.

I knew I’d necessarily have to find an OS X equivalent if I wanted to ever work on the Mac (well, that and a Wacom tablet that’s not coming… ah, and being able to share my PC’s WWW directory without it being accessible to everyone without a password — turns out you have to define a password for your guest user: net user guest password after you have enabled the guest account) but I wasn’t in quite a hurry to look for a solution, being too afraid not to find it.

Turns out it’s not only possible, it’s actually quite simple: you only have to install Transmit, configure all your sites as favorites (paying attention to set the correct local and remote paths so Transmit can accurately determine where files are supposed to go), check the “DockSend” checkbox for each site, and… you’re done. Drag and drop files onto the Transmit icon, they’re uploaded to where they belong.

Now you’ll want to get TextWrangler to send its files to Transmit — drag-and-drop is fine for occasional use but quickly becomes a nuisance. Open your Library : Application Support : TextWrangler : Scripts folder, create a Upload Using Transmit.scpt file with this:

set fileName to “”
tell application “TextWrangler”
  save document 1 of window 1
  set fileName to (file of document 1 of window 1)
end tell
tell application “Transmit”
  open fileName
end tell
tell application “System Events”
  set this app to some item of (get processes whose name = “Transmit”)
  set visible of this app to false
end tell

Go back to Text Edit, check the Window / Palettes / Scripts menu option, select the newly created script and define a keyboard shortcut.

Explaining it all makes for a pretty long (and boring) post, but it’s so much simpler than learning C# and coding my own program. It works with only a few lines of scripting, and I can now manage my websites without having to move over to the PC’s keyboard. And you have no idea how much that changes everything.

What are you waiting for to get a Mac?