tags:

views:

33

answers:

1

I've thought that mate is virtually the same as 'open -a TextMate.app', but I guess I'm wrong in this.

As when I run the following command, when there's no hello2.txt, I get this error.

open -a TextMate.app hello2.txt
The file /Users/smcho/hello2.txt does not exist.

But, it's OK to run mate.

mate hello.txt --> opens the text mate. 

What's the difference between the two?

I even tried

open -a TextMate.app --args hello2.txt

But this time, TextMate run with the file name 'Untitled', not 'hello2.txt'.

And this code opens the 'hello3.txt' without any problem.

[NSTask launchedTaskWithLaunchPath:@"/Applications/TextMate.app/Contents/MacOS/TextMate"     arguments:[NSArray arrayWithObjects:@"hello3.txt", nil]];
+1  A: 

open will open the given file with the default or a specific application.

open -a TextMate.app hello2.txt

means "Open the file hello2.txt using the application TextMate.app".
If there is no hello2.txt, there's nothing open could open, with or without TextMate.app, hence the error.

open -a TextMate.app --args hello2.txt

means "open nothing specific in the application TextMate.app (i.e. only open TextMate.app) and pass 'hello2.txt' as additional argument". This is a different kind of argument than the first example. TextMate.app can decide what to do with that additional argument. Apparently it chooses to ignore it.

mate is a utility optionally installed by TextMate.

mate hello.txt

means "I'd like to edit a file called hello.txt in TextMate", which is exactly what TextMate will let you do. It's a different utility with different behavior and different purpose, and it seems to better suite what you want it to do.

deceze
@deceze : Thanks for clarifying, but I still don't understand why 'launchedTaskWithLaunchPath' works. It indicates that TextMate cares about the parameters (arguments:[NSArray arrayWithObjects:@"hello3.txt").
prosseek