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


Click here to return to the 'Switch Terminal dir to frontmost window of certain apps' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Switch Terminal dir to frontmost window of certain apps
Authored by: ojohns on Jul 25, '06 11:03:33AM

The editor ate the leading spaces of my previous post. This is a corrected version.

This is nifty. But I had to modify it a bit to get it to work directly from the command line.
Copy this and then paste it into a Terminal window:

function ff { osascript -e 'tell application "Finder"' \
-e "if (${1-1} <= (count Finder windows)) then" \
-e "get POSIX path of (target of window ${1-1} as alias)" \
-e 'else' -e 'get POSIX path of (desktop as alias)' \
-e 'end if' -e 'end tell'; };\
function cdff { cd "`ff $@`"; };

After pasting this into Terminal and pressing Return, then type cdff and press return. The Terminal should cd to whatever is the current Finder window.



---
ODJ



[ Reply to This | # ]
Switch Terminal dir to frontmost window of certain apps
Authored by: timcrawf on Jul 26, '06 09:18:53AM

how do I get Terminal to remember this?



[ Reply to This | # ]