Transmit 5 and iTerm

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

2019-08-20 22:06:28.678 defaults[32600:11072367] Unexpected argument Coding; leaving defaults unchanged.

Does anyone have any ideas? Any good source to turn to?

1 Like

I found this repository on GitHub which is close to which is how I use iTerm through Alfred.

AppleScript for Alfred => iTerm

It is likely easily adapted to what you’re trying to achieve.

I would try just using “iTerm2” as the application name first though.

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

What a great site you designed!
Yes, I looked at your web site, bravo!
Gatsby is so cool to work with.
Nice nice nice!

Haha thanks! Such a joy to use. For a while I forgot how to do development in react without using gatsby :grin:

1 Like

Hmm, giving me the same error that the original script I tried was…

defaults[30404:2545505] Unexpected argument Coding; leaving defaults unchanged. 2019-09-02 12:13:58.243 defaults[30404:2545505] Unexpected argument Coding; leaving defaults unchanged.

GAH, I can’t believe how dumb I am. I’m so used to pasting path into iTerm auto-escaping any spaces, but it wasn’t. It’s working fine now.

1 Like