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 10:53:54AM

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 $@`"; };

Note the space before each -e. 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 | # ]