[TxMt] external Editor

Takaaki Kato devlist at samuraicoder.net
Mon Apr 14 13:02:33 UTC 2008


I tried the code, as Hans writes in the comment, you need to quit the  
app not just close the window. It would be great if closing the window  
writes back to TM document.


Takaaki
-- 
Takaaki Kato
http://samuraicoder.net

On Apr 14, 2008, at 6:51 PM, Hans-Joerg Bibiko wrote:
> If someone is interested here's the code:
> [I do not have CSSEdit but it should work and, of course, the code  
> can be optimized ;)]
>
> tmcommand:
> Input: selection or nothing
> Output: replace selected text
> Save: nothing
> Command:
>
> # get indention
> HEAD=$(echo -en "$TM_SELECTED_TEXT" | head -n 1 | perl -ne 'm/ 
> ^([\t ]*)/;print $1')
>
> # write selection to file
> echo -en "$TM_SELECTED_TEXT" | perl -pe "s/^$HEAD//g;" > /tmp/tm.css
>
> # open CSSEdit
> open -a CSSEdit /tmp/tm.css
>
> # wait for CSSEdit (it must be quitted!)
> while [ `ps -ax | grep 'CSSEdit\.app' | wc -l` == "1" ]
> do
> 	sleep 0.5
> done
>
> # write file back to TM
> if [ -f /tmp/tm.css ]; then
> 	cat /tmp/tm.css | sed "s/^/$HEAD/"
> 	rm /tmp/tm.css
> else
> 	beep
> 	exit_discard
> fi
>
> Scope Selector: source.css




More information about the textmate mailing list