Skip to content

Instantly share code, notes, and snippets.

@Snesi
Forked from johnfmorton/TransmitOpenTerminal.txt
Created August 15, 2018 18:58
Show Gist options
  • Save Snesi/3de607e4e527c163cd15b1f67255d19c to your computer and use it in GitHub Desktop.
Save Snesi/3de607e4e527c163cd15b1f67255d19c 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