4

Possible Duplicate:
How do I pass command line arguments to Dock items?

On a Windows PC, if I need to provide any launch options to an application (say, Chrome browser), I can do that by creating a shortcut to Chrome.exe and adding the options to the end of the shortcut's Target property.

How can I do the same thing on a Mac? Specifically I need to pass some launch options to my Firefox/Chrome browser. I'm running Mac OS X 10.7.3.

0

2 Answers 2

4

In Unix systems (of which OS X is one), options to programs are given at the command line, normally preceeded by "-". So, to run firefox with, for example a private session, open a terminal and enter:

 $ firefox -private

If you want to make this the default, every time you run firefox, you can create a BASH alias. Edit the file .profile in your user's home directory and add this line:

alias firefox="firefox -private"

Once you save that file, everytime you run firefox you will run it with the desired options.

Finally, to get a list of the command line options available to firefox, run firefox -h from a terminal. The following is the output on Linux:

$ firefox -h
Usage: firefox [ options ... ] [URL]
       where options include:

X11 options
  --display=DISPLAY  X display to use
  --sync             Make X calls synchronous
  --g-fatal-warnings Make all warnings fatal

Firefox options
  -h or -help        Print this message.
  -v or -version     Print Firefox version.
  -P <profile>       Start with <profile>.
  -migration         Start with migration wizard.
  -ProfileManager    Start with ProfileManager.
  -no-remote         Do not accept or send remote commands; implies -new-instance.
  -new-instance      Open new instance, not a new window in running instance.
  -UILocale <locale> Start with <locale> resources as UI Locale.
  -safe-mode         Disables extensions and themes for this session.
  -jsconsole         Open the Error console.
  -browser           Open a browser window.
  -new-window  <url> Open <url> in a new window.
  -new-tab     <url> Open <url> in a new tab.
  -preferences       Open Preferences dialog.
  -search     <term> Search <term> with your default search engine.
  -private           Enable private browsing mode.
  -private-toggle    Toggle private browsing mode.
  -setDefaultBrowser Set this app as the default browser.
2
  • Is there a "nonglobal" way of achieving alias?
    – Pacerier
    Dec 15, 2017 at 16:27
  • @Pacerier this isn't global, it only affects your user. But on OSX, you should use ~/.profile, not ~/.bashrc.
    – terdon
    Dec 15, 2017 at 16:32
3

From the command line, you can use the following:

open -a ProgramName --args your program arguments

Since OS X applications are packages as application bundle and their binaries aren't usually on the $PATH, the usual "Unix way" of launching applications is usually too complicated unless you're willing to alias or ln -s everything. Compare (if you installed Firefox to the default applications folder):

open -a Firefox
/Applications/Firefox.app/Contents/MacOS/firefox

For passing command-line options as arguments without opening Terminal, see this post.

Not the answer you're looking for? Browse other questions tagged .