Hi,
is it possible to call an external editor (e.g. CSSEdit) from Textmate?
you could make a tmcommand that uses the 'open -a …' terminal command to upen the current file in something else. Then saving the file somewhere else and switching back to tm will refresh the contents. On Apr 13, 2008, at 4:13 PM, Daniel Hoffmann wrote:
is it possible to call an external editor (e.g. CSSEdit) from Textmate?
I believe you can right click on the item when it's in the project drawer, and choose "Open With..." and it should have CSSedit as a choice for CSS files. If you're editing the file outside TM, it should refresh within TM, when you switch back I believe.
-Kevin
On Sun, Apr 13, 2008 at 4:13 PM, Daniel Hoffmann d.hoffmann@mac.com wrote:
Hi,
is it possible to call an external editor (e.g. CSSEdit) from Textmate?
View this message in context: http://www.nabble.com/external-Editor-tp16625438p16625438.html Sent from the textmate users mailing list archive at Nabble.com.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On Sun, Apr 13, 2008 at 10:00 PM, Kevin Ridgway kridgway@gmail.com wrote:
I believe you can right click on the item when it's in the project drawer, and choose "Open With..." and it should have CSSedit as a choice for CSS files. If you're editing the file outside TM, it should refresh within TM, when you switch back I believe.
I could not get this to work. I'd love to have that option though if anyone else can sort it out.
~jerad
On 14 Apr 2008, at 07:55, Jerad wrote:
On Sun, Apr 13, 2008 at 10:00 PM, Kevin Ridgway kridgway@gmail.com wrote: I believe you can right click on the item when it's in the project drawer, and choose "Open With..." and it should have CSSedit as a choice for CSS files. If you're editing the file outside TM, it should refresh within TM, when you switch back I believe.
I could not get this to work. I'd love to have that option though if anyone else can sort it out.
Step 1.
close textmate.
step 2
Open finder, browse for a CSS file, ctrl click and get info - set the open with option to CSS Edit and apply to all files of type CSS
step 3
Open Textmate.
rightclicking the CSS item in the project pane will now offer the option to open with CSS Edit.
of course, henceforth all css files will by default be opened in CSS Edit, but that may be a non-issue.
in order for TM to refresh the file view (if you have it opened in another editor as well as TextMate, you will need to save the file in the other editor
hth
;)
On Mon, Apr 14, 2008 at 8:08 AM, Tony Crockford tonyc@boldfish.co.uk wrote:
On 14 Apr 2008, at 07:55, Jerad wrote:
On Sun, Apr 13, 2008 at 10:00 PM, Kevin Ridgway kridgway@gmail.com wrote: I believe you can right click on the item when it's in the project drawer, and choose "Open With..." and it should have CSSedit as a choice for CSS files. If you're editing the file outside TM, it should refresh within TM, when you switch back I believe.
I could not get this to work. I'd love to have that option though if anyone else can sort it out.
Step 1.
close textmate.
step 2
Open finder, browse for a CSS file, ctrl click and get info - set the open with option to CSS Edit and apply to all files of type CSS
Yup, I've just done that. I thought of that whilst walking my son to school and could only hope I'd get the solution posted first. Obviously this works for setting the external editor for image files as well.
Anyway, thanks Tony; excellent as usual.
~jerad
On 14 Apr 2008, at 10:31, Jerad wrote:
On Mon, Apr 14, 2008 at 8:08 AM, Tony Crockford tonyc@boldfish.co.uk wrote:
On 14 Apr 2008, at 07:55, Jerad wrote: On Sun, Apr 13, 2008 at 10:00 PM, Kevin Ridgway kridgway@gmail.com wrote: I believe you can right click on the item when it's in the project drawer, and choose "Open With..." and it should have CSSedit as a choice for CSS files. If you're editing the file outside TM, it should refresh within TM, when you switch back I believe.
I could not get this to work. I'd love to have that option though if anyone else can sort it out.
Step 1.
close textmate.
step 2
Open finder, browse for a CSS file, ctrl click and get info - set the open with option to CSS Edit and apply to all files of type CSS
An other approach is to use a tmcommand a la:
open -a CSSEdit "$TM_SELECTED_FILE"
For me there is no need to open css file as default with CSSEdit (my default is TextMate ;).
On the other hand it would also be possible to use CSSEdit as CSS editor for CSS definitions specified inside an HTML file. You select the CSS stuff, the selection will be saved as /tmp/tm.css, this file will be opened in CSSEdit, and if you save that file and close CSSEdit the content of /tmp/tm.css will be inserted in TM.
--Hans
On the other hand it would also be possible to use CSSEdit as CSS editor for CSS definitions specified inside an HTML file. You select the CSS stuff, the selection will be saved as /tmp/tm.css, this file will be opened in CSSEdit, and if you save that file and close CSSEdit the content of /tmp/tm.css will be inserted in TM.
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
To kill this command simply press APPLE+.
--Hans
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
On 14 Apr 2008, at 15:02, Takaaki Kato wrote:
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.
Well, without AppleScript I guess it's a bit tricky to do it, but you can try the following:
... # wait for CSSEdit (it must be quitted) touch /tmp/tm_css.tmp while [ `ps -ax | grep 'CSSEdit.app' | wc -l` == "1" ] do sleep 0.5 [[ /tmp/tm.css -nt /tmp/tm_css.tmp ]] && break done
# write file back to TM if [ -f /tmp/tm.css ]; then cat /tmp/tm.css | sed "s/^/$HEAD/" rm /tmp/tm.css rm /tmp/tm_css.tmp else beep exit_discard fi ...
That means, IF you quit CSSEdit OR you save the document in CSSEdit, TM will get the current content. But this works only once. Once you have saved that file TM won't be notified about further changes. One could write an HTML output window command, where you define a JavaScript loop using TextMate.system() as a kind of a listener, but I do not know how stable and/or useful it will be.
Maybe to use AppleScript would be better. But, as I already mentioned, I do not have CSSEdit.
--Hans