On May 24, 2007, at 8:50 PM, Jay Soffian wrote:
Not perfect as it slams everything into the environment, not just the project variables; As well, its escaping of the environment variable values is naive. And it assumes tcsh. But it's a start.
Final (sure...) version attached with aforementioned items resolved.
============================================ 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
tmpfile=`mktemp -t tmvars` case $SHELL in */tcsh) env | grep -v '^TM_' \ | sed 's/([^A-Za-z0-9_=])/\\1/g; s/([^=]*)=(.*)/if (! $? \1) setenv \1 \2/' \ > $tmpfile ;; */bash) env | grep -v '^TM_' \ | sed 's/([^A-Za-z0-9_=])/\\1/g; s/([^=]*)=(.*)/ [[ "\1" ]] || export \1=\2/' \ > $tmpfile ;; *) > $tmpfile ;; esac
osascript <<EOF tell application "Terminal" activate do script "cd '$TM_PATH'; source $tmpfile; rm -f $tmpfile; clear; pwd" end tell EOF ============================================
zsh users might wish to confirm that the bash syntax works (I think it does...) and then modify the case statement to suit.
Thoughts?
j.