Skip to content

Instantly share code, notes, and snippets.

@sthembi
Forked from johnfmorton/TransmitOpenTerminal.txt
Last active August 20, 2018 02:39
Show Gist options
  • Save sthembi/79ba8b988a30bbf098662e7b751349b7 to your computer and use it in GitHub Desktop.
Save sthembi/79ba8b988a30bbf098662e7b751349b7 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 & "\"; eval \"$SHELL -il\"'"
set sshCommand to "ssh -t " & "'" & remoteHost & "'"
else
set cdCommand to "cd \"" & location & "\""
end if
if (serverPort is greater than 0) then
set sshCommand to sshCommand & " -p " & serverPort
end if
if ((count of location) is greater than 0) then
set sshCommand to sshCommand & cdCommand
end if
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
@sthembi
Copy link
Author

sthembi commented Aug 9, 2018

updated Gist to have iTerm open and log into the same directory in view on Transmit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment