What's the difference between 'open -a TextMate.app' and 'mate'?
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.开发者_StackOverflow社区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]];
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.
精彩评论