Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: Use Automator to open chosen folder in Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Use Automator to open chosen folder in Terminal
Authored by: mrodkey on Aug 31, '05 06:14:06PM

This does not work your terminal window is open to with SSH session. It tries to execute the cd command on the remote host. So unless you always keep your first terminal window local only it may be best to modify this to always create a new window.



[ Reply to This | # ]
10.4: Use Automator to open chosen folder in Terminal
Authored by: juanfal on Sep 01, '05 06:44:14AM
No.

If the front-most window is doing ssh, Terminal (at least, I don't know iTerm), considers itself "busy", then the script will open a new window, as fabrizio points, since the "do command" without reference to any window issues the command in a fresh new window.
Then the last version:
on run {input, parameters}
	tell application "Terminal"
		activate
		if (the (count of the window) = 0) or (the busy of window 1  = true) then
			do script "cd " & (quoted form of POSIX path of  (input as string))
		else
			do script "cd " & (quoted form of POSIX path of  (input as string))  in window 1
		end if
	end tell
	return input
end run
     

[ Reply to This | # ]
10.4: Use Automator to open chosen folder in Terminal
Authored by: mrodkey on Sep 01, '05 07:07:54PM

Yes :)

I copied and pasted the above script into automator and saved it as a finder plug-in. my 1 Terminal window was an ssh session to a remote machine and the behavior I observed was that the cd command was sent to that window and not a new one.

Reproduction Steps:
open terminal
ssh to remote host (with command ssh zlinux )
switch to terminal and run the above action on a file or folder

here are the results ...
[mrodkey@zlinux mrodkey]$ cd '/Users/mrodkey/'
-bash: cd: /Users/mrodkey/: No such file or directory

(zlinux is a remote machine)



[ Reply to This | # ]
10.4: Use Automator to open chosen folder in Terminal
Authored by: juanfal on Sep 01, '05 08:17:43PM

Ok, you are wright. You can remove 'ssh' from the 'don't alert on close' preference or look specifically for that kind of process in the title of the front-most window or, finally make _always_ a new window. I prefer not to make new windows when possible.



[ Reply to This | # ]
10.4: Use Automator to open chosen folder in Terminal
Authored by: dkulp on Jan 25, '06 11:36:34AM
I want to right click on a folder or a file. If a file then it should open the terminal in the enclosing folder.


on run {input, parameters}
	
	tell application "Terminal"
		activate
		set p to (quoted form of POSIX path of (input as string))
		set s to "if [ -d " & p & " ]; then cd " & p & "; else cd `dirname " & p & "`; fi"
		if (the (count of the window) = 0) or (the busy of window 1 = true) then
			do script s
		else
			do script s in window 1
		end if
	end tell
	return input
end run


[ Reply to This | # ]