I looked into this early on in textmate's life, but never found a solution that I would call graceful. However, the work recently done by Hans connecting to R in textmate may provide some inspiration. Also, there was a terminal plugin based on iterm built as a proof of concept some time ago that could also perhaps be used, but I never had much success getting that running, and I don't know that it's still actively maintained.
-d