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


Click here to return to the 'Open anything in TextMate via an AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open anything in TextMate via an AppleScript
Authored by: wgscott on Nov 08, '06 03:47:37PM
Here is a zsh shell script (or function) to cd to the directory displayed in the frontmost textmate window:
#!/bin/zsh -f

#  cdt

        DocPath="$(osascript -e 'tell app "TextMate" to return path of first document')" 
        DocDir="$(dirname "$DocPath")" 
        print "The frontmost TextMate file is $DocPath"
        fdc () {
                if [ -n "$1" ]
                then
                        if [ "${1%%/*}" = "" ]
                        then
                                thePath="$1" 
                        else
                                thePath="$(pwd)""/$1" 
                        fi
                else
                        thePath="$(pwd)" 
                fi
                osascript  /dev/null
                print "Changing Finder display to $DocDir"
                print "Current Working Directory remains $PWD"
        elif [[ $1 = "-F" ]]
        then
                command cd $DocDir
                fdc $DocDir > /dev/null
                print "Changing directory and Finder display to $PWD"
        else
                command cd $DocDir
                print "Changing directory to $PWD"
        fi




[ Reply to This | # ]