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


Click here to return to the 'A script to automatically open a Terminal window to its directory' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to automatically open a Terminal window to its directory
Authored by: regulus on Jun 28, '11 08:31:22PM
The hint is OK except for the fact that you have to place a copy of the script in every folder where you want this to work. Why not have 1 script that works no matter which folder you are in? Here's that. Just put this in your Script menu and then it's accessible any time from any folder.
tell application "Finder" to set f to (target of window 1) as text
tell application "Terminal" to do script "cd " & quoted form of POSIX path of f
NOTE: to show the script menu open AppleScript Editor, under preferences check the box "Show Script Menu". Then add this script to that menu by placing it in the folder ~/Library/Scripts.
---
Hank
http://www.hamsoftengineering.com


[ Reply to This | # ]
A script to automatically open a Terminal window to its directory
Authored by: Lri on Jul 06, '11 02:25:32AM
tell application "Finder" to set il to insertion location as alias
set cmd to "cd " & quoted form of POSIX path of il
tell application "Terminal"
	activate
	try
		do script with command cmd in window 1
	on error
		do script with command cmd
	end try
end tell
  • Doesn't always open a new window
  • Makes the Terminal window frontmost
  • Uses insertion location, so it works on for example Desktop


[ Reply to This | # ]