Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Am I missing something...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Am I missing something...
Authored by: serversurfer on Nov 11, '01 11:33:59PM
or is all of this kind of a waste of time?
First of all, the original poster suggested you call the script 'openApplication' Then, to avoid having to type openApplication all the time, he says you should alias it to 'o'. Is there some reason for not calling the script 'o' in the first place?
Second, and perhaps most important, it seems to me that all this script does is reduce the functionality of the open command. open, on its own, is case-insensitive, handles spaces in app/file names (just quote them), opens Carbon applications (which don't have an '.app' extension), and, best of all, it automagically searches down in to your entire Application tree to find the app in question (This includes /Applications ~/Applications and even /Developer/Applications. I presume it also searches /Network/Applications, but I can't test this on my setup.)
So for example, the command
open -a "appleworks 6" ~/documents/budget.cwk

executed from any directory, opens my Budget in AppleWorks, which resides in "/Applications/Productivity/Office/AppleWorks 6/Appleworks 6.app".
open -a "quartz debug"

will open "/Developer/Applications/Quartz Debug.app"
open -a "contract timer"

will open "~/Applications/Contract Timer" which is a Carbon app in my home app folder (which must be called Applications). As a matter of fact,
open -e readme

will still open the readme with TextEdit, even though it now lives in "/Applications/Productivity/Editors/TextEdit.app". (The man page states it must live in /Applications)
So, unless someone can demonstrate that I am an idiot, and you are looking to save a few keystrokes, I would recommend that you just
alias o 'open -a'

This will let you open iTunes by typing
o itunes

regardless of where you moved it, as long as it's still downstream of an Applications folder that resides in '/' '~/' '/Developer/' or '/Network'
Furthermore, open also uses the "default" application defined in the Finder to open files. So in the first example, you could just type
open ~/documents/budget.cwk

and open will use AppleWorks automatically.
Like I said, if I'm missing something, let me know, but I just tested all of these tips and they all work on my 10.1 iBook466.
P.S. Can anyone get StuffIt Expander to open on a remote machine? The open command works on a local box, but on a remote, it always reports
kCGErrorIllegalArgument : CGSNewConnection cannot get connection port

kCGErrorIllegalArgument : CGSNewConnection cannot get connection port
kCGErrorInvalidConnection : CGSGetEventPort: Invalid connection


[ Reply to This | # ]
Yes :-)
Authored by: sabi on Nov 12, '01 12:04:58AM

Locating an application by name does not work if you've renamed the
application. Consider the standard practice of including an
application's version in its name, e.g. (picking one example on my
hard disk) "Adobe GoLive 5.0". Once you upgrade to GoLive 6, all your
scripts that refer to it will break. This is why matching an
application by name is not the answer. See my post above, a decent
replacement for 'open' would match apps by creator and/or bundle ID,
neither of which change no matter where you move the application. Of
course there are still issues if you have multiple versions of an
application installed.



[ Reply to This | # ]
Perhaps,but...
Authored by: serversurfer on Nov 12, '01 03:19:01AM
I renamed ~/Applications/Xoptimize/Xoptimize to Xoptimize2 in the Finder then used the duplicate menu item on it. Then, in the terminal, I executed
o xoptimize2

o "xoptimize2 copy"

This opened two copies of Xoptimize side by side. I didn't have to log out or even rehash. They both still thought they were called Xoptimize, but they operated independently of each other. (X rules)
I don't disagree that your program looks pretty cool. The 'open owner of this pref' option seems interesting enough on its own. I'm just saying that for opening apps and their data files from the terminal open does the job pretty well. And as far as breaking all your old scripts when you update/rename your app, just run the scripts through sed. Besides, that's why you shouldn't put version numbers in the bin name.
BTW, is your app called launch or FindApp? :-)

[ Reply to This | # ]
Am I missing something...
Authored by: littlebilly on Nov 12, '01 01:36:01PM

The long name of the script is just to reduce confusion when I want to edit, remove or replace a script. As for your second point... not having to type the full path name.. Your right. I have already quit using this script. Is this new to 10.1? Before upgrading I am pretty sure I had to type the full path.. hence the script. Thanks for pointing that out, I would have gone on using my "limited features" script.



[ Reply to This | # ]
New to 10.1?
Authored by: serversurfer on Nov 12, '01 07:16:21PM
I'm pretty sure that it has always been this way. I don't recall ever typing a path myself. I reread the man page just now (still dated Mar. 24, 2001) and it states
You can specify one or more file names (or pathnames), which are interpreted relative to the shell or Terminal window's current working directory.
Perhaps this line caused your confusion. At first glance, it seems to be telling you to specify any needed pathnames, but I think this line only refers to the file argument not the application arg. Since it uses the "default" app automatically if unspecified, this means it already had some ability to search on its own. It is possible that open 10.0.x only searched '/Applications' (where 98% of my apps reside) and not the other appdirs, like '~/Applications', but I kind of doubt it, since all four appdirs have always been considered part of the Application tree. See Inside Mac OS X: System Overview pages 166 and 242.
I have been meaning to install X on my parent's iMac. Whenever I finally get around to it, I'll test this before I upgrade them to 10.1 as post back here. Unless someone out there is still running 10.0.x and can beat me to the punch. (What's wrong with you anyway? X.1 rules! ;-) )

P.S. You can even use a directory as the file arg and open will open a new Finder window in that directory.

open ~

If the specified directory is already the focus of a Finder window, Finder will bring that window to the front rather than open a new one.

[ Reply to This | # ]
New to 10.1?
Authored by: littlebilly on Nov 19, '01 03:21:04PM

I figured out why I had to type the whole path-- I wasn't using the -a option! so i was using
open /Applications/TextEdit.app to open from the terminal.
I have 10.04 installed on another drive and it is the same.
A couple of seconds spent looking at the man page would have saved me some trouble.



[ Reply to This | # ]