[TxMt] Re: Opening Links in TextMate

Rob McBroom textmate at skurfer.com
Tue Nov 4 20:38:45 UTC 2008

On 2008-Nov-4, at 6:22 AM, Wolfgang wrote:

> is there a way to create a shortcut to open the linked css-files in
> another window or in CSSEdit?

I'm sure it can be done. I haven't worked it all out, but hopefully  
this will get you started…

You would create a command with some keystroke that runs `mate  
some_path` or `open -a CSSEdit some_path`. Now, all you need is the  
right path. (I've never called `mate` from within TextMate. Anyone  
know if there are problems with this?)

You'll probably need to parse $TM_CURRENT_LINE to get the filename.  
The tricky part will be dealing with both absolute and relative paths  
in the href attribute and translating them to paths on the local  

For relative paths, I think it might be safe enough to just combine  
$TM_DIRECTORY and the value of the href attribute. For absolute paths  
(that start with '/'), $TM_PROJECT_DIRECTORY will probably work as a  
prefix (if you're in a project), but there's no guarantee. Outside of  
a project, I don't know. You might have to just look in $TM_DIRECTORY  
for the CSS path, then if you don't see it, check the parent  
directory, and keep going up until you find it.

So, if $TM_DIRECTORY is /Users/rob/Projects/web/foo/ and the link says  
href="/styles/blah.css", you would check these paths in the following  


Of course the last 2 or 3 are ridiculous, so you could make it smart  
enough to skip those, but you get the idea. Good luck.

Rob McBroom

Because it screws up the order in which people normally read text.

Original message:

> Why is it bad to top-post your reply?

More information about the textmate mailing list