Skip to content

Instantly share code, notes, and snippets.

@niladam
Forked from johnfmorton/TransmitOpenTerminal.txt
Created October 24, 2017 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niladam/55fe161b31ce385b388ff3c944ff491d to your computer and use it in GitHub Desktop.
Save niladam/55fe161b31ce385b388ff3c944ff491d to your computer and use it in GitHub Desktop.
Use Transmit 5 to open in iTerm (instead of Terminal.app) as mentioned here https://library.panic.com/transmit5/open-in-terminal/
on openTerminal(location, remoteHost, serverPort)
tell application "System Events"
-- some versions might identify as "iTerm2" instead of "iTerm"
set isRunning to (exists (processes where name is "iTerm")) or (exists (processes where name is "iTerm2"))
end tell
tell application "iTerm"
activate
set targetTab to ""
set sshCommand to ""
if ((count of remoteHost) is greater than 0) then
set cdCommand to "cd " & location
set sshCommand to "ssh " & remoteHost
else
set cdCommand to "standalone"
end if
if (serverPort is greater than 0) then
set sshCommand to sshCommand & " -p " & serverPort
end if
set command to sshCommand
set hasNoWindows to ((count of windows) is 0)
if isRunning and hasNoWindows then
create window with default profile
end if
select first window
tell the first window
if isRunning and hasNoWindows is false then
create tab with default profile
end if
if ((count of sshCommand) is greater than 0) then
tell current session to write text sshCommand
tell current session to write text cdCommand
end if
end tell
end tell
end openTerminal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment