<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">I tried to write an applescript that opens the source code of the frontmost Safari window in TextMate (that what happens when you press Cmd-Alt-U in Safari, but with TM instead of the internal viewer). So, I asked in the IRC how to open a file in TextMate via Applescript. I was told that TM does not support Applescript and I should curl the source and open that via open -a instead.<DIV><BR class="khtml-block-placeholder"></DIV><DIV>Well, this would work, but for my simple purpose, it could be done easier; I mean, we got the source already in Safari, so why start a curl download?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>After some try and error, I found out that the command line tool tm is all I need:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>-- Script start --</DIV><DIV>tell application "Safari"</DIV><DIV>    set mySource to the source of document 1 as string</DIV><DIV>end tell</DIV><DIV>do shell script ("echo " & quoted form of mySource & " | /usr/local/bin/tm -a")</DIV><DIV>-- Script end --</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;">tm must be installed in /usr/local/bin to work in this script. This echos the source code into a file in /tmp and opens it in TM. I binded it to my Hotkey-App and open it via Cmd-Alt-U in Safari. Works nice.</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;">Aaron</SPAN></FONT></DIV></BODY></HTML>