[TxMt] Open command

Cliff Pruitt lists.cpruitt at cliffpruitt.com
Tue Jun 12 12:45:57 UTC 2007


On Jun 11, 2007, at 7:51 AM, Chuck Esterbrook wrote:

> I was wrong. ⌘O still needs improvement. Today I did "mate foo bar"
> from the command line. Well okay, the first issue is that the two
> files were put in a file drawer, but not actually opened up. I was
> expecting to see the contents of at least one of them and preferably
> have windows or tabs for both.
>
> But getting back to ⌘O, I clicked on "foo" and read through it. I
> clicked on "bar" and read through it. Then I realized I needed "baz"
> and hit ⌘O at which point I was looking at some directory totally
> unrelated to the one that "foo" and "bar" were located in. I had to
> poke around to get to where "foo" and "bar" were, but after two pokes
> I said screw it and went back to the command line to type "mate"
> again.
>
> So my suggestion is that ⌘O set the directory to the directory of  
> the
> currently edited file. It's more likely to be useful as I've
> experienced in other applications.
>
> -Chuck

As I understand it, the mate command line tool is not at all the same  
as the TextMate application (its just a little helper utility), so it  
would not (and really should not) have any bearing on the stored path  
for opening new folders.  Think of it this way:

In its current incarnation text mate expects that you're doing things  
in a somewhat standard way.  If you're in the terminal dinking around  
then you've probably cd'd to the directory you're working in.  If  
you've opened foo & bar & realize you need baz, just cmd+tab back to  
terminal & 'mate baz'.  If you're the kind of person that uses the  
open command a lot, TM assumes you're probably still working on  
whatever you last opened from the open dialog.

What is TM going to show me if I'm working on a new document that  
hasn't been saved yet?  What about something I'm editing using the  
"Edit in Text Mate" command?  What will it show me if nothing is  
opened?  Why would it think I've changed what I'm working on just  
because I've un-minimized some 30 minute old readme file from the  
dock that I've since moved into the trash but its still open in TM?

The point is, I can see where you're coming from but I think TM's  
behavior is correct for most people, most of the time.  There are  
always exceptions and sometimes some people tend to be more of an  
exception that a rule, but it's not a problem with the app's command  
itself, its just that it doesn't match your workflow.

But honestly, if you want a solution, why not just do this:
Create a new bundle command and give it whatever tab trigger/shortcut/ 
scope you want and put this into it:

#------------------------------
osascript <<-APPLESCRIPT
	set TMVar to "${TM_FILEPATH}"
	tell application "System Events"
		set openLocation to alias TMVar
		set filePath to POSIX path of ((choose file default location  
openLocation) as alias)
		do shell script "mate " & quoted form of filePath
	end tell
APPLESCRIPT
#------------------------------

That command will open a standard open dialog that defaults to your  
current file's path.  It could probably be streamilned & shortened  
even but I kind of slapped it together.  Anyway, it should give you  
what you need.

- Cliff










More information about the textmate mailing list