Not sure if there’s a better forum to ask this question; I’ve picked up Transmit by Panic, and I’m interested in configuring the “Open in Terminal” command to open iTerm instead of Terminal.app. Panic’s own documentation talks through how to change this, but I’m not sure what to actually put in the replacement. I’ve tried using this as my file, but I keep getting
I’m also using Alfred with iTerm, though I forget what script I copied over. I lack the AppleScript experience I need to pass the right information over from Transmit, though.
I have no way of testing this but this is best I came up with…
Code
on openTerminal(location, remoteHost, serverPort)
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
if application "iTerm2" is running or application "iTerm" is running then
run script "
on run {sshCommand}
tell application \"iTerm\"
activate
try
select first window
set onlywindow to true
on error
create window with default profile
select first window
set onlywindow to true
end try
tell the first window
if onlywindow is false then
create tab with default profile
end if
tell current session to write text sshCommand
end tell
end tell
end run
" with parameters {sshCommand}
else
run script "
on run {sshCommand}
tell application \"iTerm\"
activate
try
select first window
on error
create window with default profile
select first window
end try
tell the first window
tell current session to write text sshCommand
end tell
end tell
end run
" with parameters {sshCommand}
end openTerminal