On 11/1/06, William Scott wgscott@chemistry.ucsc.edu wrote:
OK, I think this should work for iTerm. It opens a new tab and goes to the directory corresponding to the file displayed in the frontmost TextMate window:
tell application "TextMate" set ThePath to path of the first document end tell
set ArgString to "cd $( dirname " & ThePath & ")"
tell application "iTerm" make new terminal tell the first terminal activate current session launch session "Default Session" tell the last session write text ArgString end tell end tell
end tell
Here is the command I use:
if [[ -d $TM_SELECTED_FILE ]]; then TM_PATH="$TM_SELECTED_FILE" elif [[ -f $TM_SELECTED_FILE ]]; then TM_PATH="`dirname "$TM_SELECTED_FILE"`" else TM_PATH="`dirname "$TM_FILEPATH"`" fi
osascript <<EOF tell application "iTerm" activate if exists the first terminal then set myterm to the first terminal else set myterm to (make new terminal) end if tell myterm activate current session launch session "Default Session" tell the last session write text "cd '$TM_PATH'; clear; pwd" end tell end tell end tell EOF
-- FredB