Alfred/iTerm/ssh

I’m a very happy Alfred and iTerm2 user on OSX.

I spent 30mins last night writing an Applescript Alfred extension to help me launch new tabs directly into iTerm and execute the ssh command directly. This means if you have ssh keys setup then it means a simple Alfred command can launch a new ssh session in a new tab in iTerm.

Applescript for the extension :

-- change this to ssh you want to run  
set myCommand to  "ssh -i /Users/goul/keys/myspecialkey.pem ec2-user@my.host.name"  
  
  
-- this will send it to iTerm  
tell application "iTerm"  
	activate  
	set myterm to (current terminal)  
	-- talk to the new terminal  
	tell myterm  
		set mysession to (make new session at the end of sessions)  
		-- talk to the session  
		tell mysession  
			-- set some attributes  
			exec command myCommand  
		end tell  
	end tell  
end tell