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


Click here to return to the 'another version' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
another version
Authored by: hayne on Oct 04, '05 09:10:26AM
Here's my version of that Bash function. (This uses the more modern $( ... ) mechanism for command substution and uses a "here" document to make the layout clearer.)

# cdf: cd's to frontmost window of Finder
cdf ()
{ 
    currFolderPath=$( /usr/bin/osascript <<"    EOT"
        tell application "Finder"
            try
                set currFolder to (folder of the front window as alias)
            on error
                set currFolder to (path to desktop folder as alias)
            end try
            POSIX path of currFolder
        end tell
    EOT
    )
    echo "cd to "$currFolderPath""
    cd "$currFolderPath"
}


[ Reply to This | # ]
missing backslashes
Authored by: hayne on Oct 04, '05 09:16:13AM
The [ code ] tags didn't work to completely preserve what I posted above. It removed the backslashes before the two interior quotes in the 'echo' line. It should be:

echo "cd to "$currFolderPath""


[ Reply to This | # ]
missing backslashes (take 2)
Authored by: hayne on Oct 04, '05 09:20:04AM

Arrgh!
I tried to make the backslashes come out by putting double-backslashes and this seemed to work in the preview, but as you see, the backslashes in my above comment still got eaten up upon submission.
I'm giving up on this, but just add in a backslash before the two " symbols that are inside the quoted string in that 'echo' line.



[ Reply to This | # ]
missing backslashes
Authored by: jacobolus on Oct 04, '05 11:36:51AM

To get backslashes, you need to put double backslashes, then add them again when they disappear from the input box in the preview page.



[ Reply to This | # ]
missing backslashes
Authored by: hayne on Oct 04, '05 01:37:25PM
Okay I'll try it one more time, using that technique:
The 'echo' line should be:

echo "cd to \"$currFolderPath\""


[ Reply to This | # ]