Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On Mac OS 10.6.6, I want to make a bash alias or function that will run Google Chrome. Launching Chrome is easy: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome". The problem is how to detach the Chrome process tree from Terminal.app so that when I close the terminal window, it doesn't kill Chrome. I have tried all of the following, to no avail:

"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" &

nohup "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" &
disown

screen "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

screen "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" &

Any suggestions for how to truly detach the Chrome process tree from Terminal.app? Alternatively, is there another way to make a command-line shortcut to launch and detach Chrome?


EDIT: Note that the answers to this question apply equally well for launching other applications besides just Chrome.

share|improve this question
    
Please edit your question to apply to all applications. We don't need a copy of this topic for every Mac application under the sun. –  Daniel Beck May 7 '11 at 4:26
    
Not what I meant. Since we keep track of the history of each post, there's no reason to let old content survive. I'd suggest you edit the title to be more generic ("Launch Mac application detached from Terminal" or something like that) and only use Chrome as an example. But that's just my opinion. –  Daniel Beck May 7 '11 at 4:33
    
@Daniel Feel free to make whatever edits you want. I see you have enough rep and are quite knowledgeable –  AlcubierreDrive May 9 '11 at 2:13

2 Answers 2

up vote 1 down vote accepted

Try this:

open "/Applications/Google Chrome.app"

share|improve this answer
    
Nice! Thanks. Weirdly, if you use the full path to the executable, it spawns a new terminal window: open "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" . Any idea why? –  AlcubierreDrive May 7 '11 at 4:17
    
P.S.: I plan to accept your answer in 7 minutes once the timer allows me to –  AlcubierreDrive May 7 '11 at 4:19
    
@Jon open uses Launch Services to determine what application to open a file with. If you do it like William suggests, it opens the Mac application bundle, but you start the unix binary itself, which gets a window for console output (stdout). open returns immediately, so there's not a lot of other options. You can also use open -a "Google Chrome" to let Launch Services determine which registered copy of Google Chrome to start. –  Daniel Beck May 7 '11 at 4:21
    
@Daniel Beck Apparently this also works: open -a "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" –  AlcubierreDrive May 7 '11 at 4:29
    
@Jon Sure, but what's the point? Since it's an application, it'll get started with or without the argument -a. The semantics are slightly different (open the file ... using the default application for that type, and open the application ...), but the result is the same. –  Daniel Beck May 7 '11 at 4:29
open -a "Google Chrome"

This will open Chrome without regard to where it is installed, which may be desirable over a hardcoded path.

Also note that using open differs from running the executable directly in that it will not launch a second copy of Chrome. This is correct Mac behavior; running the executable directly should not be done unless you have a special need such as passing command-line arguments (which a proper Mac application should never need in normal circumstances).

share|improve this answer
1  
open -na "Google Chrome" does open a second instance. open -a "Google Chrome" --args "someArg" passes arguments. –  Daniel Beck May 7 '11 at 18:00
    
Interesting. --args is apparently new in 10.6, but -n is new to me as well. Evidently I haven't read the man page for open in a while. –  Kevin Reid May 7 '11 at 20:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.