Here is the exact TextMate command I'm using right now. Hope this helps!
rawText="$(cat | sed 's/ / /g;')" osascript -e 'on run(theCode)' \ -e ' tell application "Terminal"' \ -e ' do script theCode in window 1' \ -e ' end tell' \ -e 'end run' -- "$rawText" open "txmt://open?line=$(($TM_LINE_NUMBER+1))&column=1000000" &

source share