I just discovered that the Terminal app can bypass the login process (it's a preference selection -- just have it run bash directly). Putting all of this together:
1. Change Terminal app preferences to start bash and not do a login.
2. Change Terminal app preferences to close the window when the shell exits.
3. Run Firefox: "open /Applications/Firefox.app &"
4. Exit the terminal window ("exit" command or Control-D).
Firefox will continue to run and Terminal window closes.
BTW, I just double-checked and when run from an Automator script automator will exit when the script is run.
No trailing '&' should be needed. The 'open' command isn't the parent process of the app it opens. The per-user launchd process is. You can use Activity Monitor to show this: select the program in the list, click Info, observe the parent process.
Also, the Automator example shown shouldn't need any Terminal preferences changes, because it's not running the shell script in Terminal. Even if Terminal is running, it doesn't run the shell script through Terminal. I don't question that the Terminal preferences changes affect Terminal windows. I only question the relevance of those changes to a Run Shell Script action in Automator. The Automator script shown should run Firefox without needing any Terminal preferences changes at all.
When referring to an app to open, using a bundle-name is better than using an absolute path, because it doesn't require the app to be installed at a specific location. The bundle-name string is identical to the CFBundleName item in the app's Info.plist. The option for 'open' is -b. The bundle-name of Firefox is org.mozilla.firefox. So a suitable command-line should be:
Code:
open -b org.mozilla.firefox
Read 'man open' for all command-line options.
Finally, the 'open' commands posted so far have neglected the
-P "ProfileName". I presume this is a critical requirement, since otherwise simply double-clicking Firefox would have the same result. In other words, the OP wants to open Firefox with a specific profile, to do so by double-clicking a Finder icon (rather than needing a direct command-line), and to not need a Terminal window or other app to remain open to keep Firefox alive. Assuming those are the requirements, the following should work:
Code:
open -b org.mozilla.firefox --args -P "ProfileName"
This single line should be pasted into a Run Shell Script action in Automator, and saved as an Application. The Run Shell Script action is located under Utilities in the Library of Actions in Automator.
Once saved as an application in Automator, double-clicking it should launch Firefox with the named profile. It will NOT relaunch Firefox if it's already running, nor will it tell an already-running Firefox to change its profile.
I don't have Firefox, so I can't test this completely. However, I tested the above with Safari's bundle name and it worked. It's not necessary to change Terminal preferences, to use nohup, or to use a trailing &.