Open in Terminal from Finder

May 17th, 2006

This is a trivial AppleScript

    tell application "Finder"
    	set targ to target of Finder window 1
    	set myPath to POSIX path of (targ as string)
    end tell

    tell application "Terminal" to do script "cd \""& myPath & "\""

Here you can see a couple of screenshots.

If you want to download the application (with pretty icon) that uses it, you can download it from here.

Edit: Thanks to Marco Balestra for showing me his own script (that does the same thing, but is much cleaner). Now I included his script instead of mine.

on run
	tell application "Finder" to try
		set myPath to quoted form of ¬
			POSIX path of ((target of window 1) as string)
	on error
		set myPath to "~"
	end try

	tell application "Terminal"
		do script "cd " & myPath
		activate
	end tell
end run

Mac, Mac Programming, Programming | Comments | Trackback

Leave a Reply

  1.  
  2.  
  3.  
  4. XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
You can keep track of new comments to this post with the comments feed.

Recent Posts

Blogroll

Siti amici

Misc

Recent Comments

Categories

Enrico Franchi graduated in Maths and Computer Science and is now studying for a Computet Science MSc (though because of italian bureaucracy that very course is to be cancelled).

RiK0's Tech Temple is using WP-Gravatar