matsuda
12/15/2010 - 3:35 PM

Open your web development project in TextMate + Transmit + Terminal (kinda like Coda)

Open your web development project in TextMate + Transmit + Terminal (kinda like Coda)

-- Coda Light
--
-- By Henrik Nyh <http://henrik.nyh.se>, 2007-04-26
-- His original script: http://henrik.nyh.se/2007/04/coda-light-applescript
--
-- Changes for Transmit 4 and AppleScript 2 by Ian Soper <http://iansoper.com>, 2010-12-15
--
-- An AppleScript to start working on a web development project by
--  * opening the project in TextMate,
--  * opening related URLs in the default browser,
--  * opening the related favorite in Transmit (FTP) and
--  * opening a related SSH session in Terminal.
--
-- Inspired by Coda <http://www.panic.com/coda/>. Coda is a trademark of Panic, Inc.



----------------------------
-- Configure here
----------------------------

-- Full path to local file, TM project or folder
set localProject to "/path/to/local/project"

-- These will be opened in the default browser
-- (Set to {} to open nothing)
set URLs to {"http://localhost/someproject", "http://someproject.com"}

-- The name of a related Transmit favorite
-- (Set to "" if you don't want to open Transmit)
set transmitFavorite to "Favorite Name"

-- SSH server
-- (Set to "" if you don't want a SSH session)
set sshServer to "example.com"
-- SSH username (set to "" to use defaults)
set sshUser to "username"
-- The SSH password must be entered manually; optionally set up DSA keys so you don't have to input it at all: see e.g. http://www.macosxhints.com/article.php?story=20011128174701140
set sshPort to "22"

----------------------------
-- Configuration ends
----------------------------

if transmitFavorite is not "" then
	tell application "Transmit"
		set myFave to item 1 of (favorites whose name is transmitFavorite)
		
		tell current tab of (make new document at end)
			connect to myFave
		end tell
	end tell
end if


if sshServer is not "" then
	tell application "Terminal"
		if sshUser is not "" then
			set sshUser to sshUser & "@"
		end if
		do script "ssh " & "-p" & sshPort & " " & sshUser & sshServer
	end tell
end if

repeat with anURL in URLs
	open location anURL -- in default browser
end repeat

if localProject is not "" then
	--	get POSIX file localProject as alias
	--	open with TextMate
	set theDir to quoted form of POSIX path of localProject as string
	do shell script "open -a TextMate " & theDir
end if