I have Chrome installed in Applications, and a shortcut to it in the Dock. How can I achieve to force some command-line arguments to each start-up of this app?

Let me be clearer, in the Terminal, I can do this: open /Applications/Google\ Chrome.app --args --explicitly-allowed-ports=6666 And that way I modify Chrome's behavior as I like it. How can I have this option by default when launching the app from the Finder of the Dock?

3 Answers 3


One way to do this is with AppleScript.

Open AppleScript Editor (/Applications/Utilities) and type this in:

do shell script "open '/Applications/Google Chrome.app'  --args --explicitly-allowed-ports=6666"

Save it as an Application, and add that application to the Dock.
Click on the app's icon and you Chrome will open with your custom parameters.

This way works, but it isn't exactly ideal for a couple reasons:

  • Running the AppleScript will take a little longer than just opening the app
  • You'll have two icons in your dock (the script and Chrome)

This will work, but I'm interested to see if someone comes up with a better answer.

  • Nathan's way is the best way. There's no code in Chrome at present to take these as a default or read a preferences file. Those switches are temporary for debugging until a feature gets added more formally - then you should have a way to change it more permanently. See chromium.org/developers/design-documents/appmode-mac for plans for helper apps. See fluidapp.com for a nice wrapper - you might be able to hack it to suit your needs (or the author might like a suggestion to extend the tool for your use case)
    – bmike
    Jul 14, 2011 at 22:38
  • "Save it as an Application, and add that application to the Dock." -- how do I save it as an Application? And trying to add a .scpt file marked as executable to the Dock just doesn't work for me under Mountain Lion: the file just doesn't "stick" to the Dock.
    – yurkennis
    Mar 14, 2015 at 18:41
  • “You'll have two icons in your dock (the script and Chrome)” You won't if you add quit on the new line in your script: it would close the script after launching Chrome then. Dec 11, 2020 at 3:49

If you go inside the app bundle (right-click on the app in Finder and select "View Package Contents") and go to the Contents/MacOS folder, there should be a file called Google Chrome whose icon is a black square. Make a note of its name and rename it (something easy like Google Chrome orig). Make a blank text file in the folder with the same name (Google Chrome) as the original file and paste in the following script:


/Applications/"Google Chrome.app"/Contents/MacOS/"Google Chrome orig" --args --explicitly-allowed-ports=6666

Make your script file executable (chmod +x "Google Chrome orig") and see if that starts Chrome properly!

  • On my Macbook the terminal shows up, and when I add the Chromium icon to the dock (when its is running by that script) I can't run it from the dock (it runs but the window does not show up)
    – Marecky
    Jan 5, 2022 at 9:47

According to Mac OS X Hints article (found by Googling mac gui application command options), this can be accomplished by editing the application's bundle. I would do this on a backup copy of Chrome to test it out first.

  1. Open the Google Chrome application bundle by right/ctrl-clicking on it and selecting Show Package Contents.
  2. Within the package, navigate to Contents/Mac OS/Google Chrome and rename it something like Google Chrome-bin.
  3. Create a text file at that same location with the name Google Chrome with the following contents:

    exec '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome-bin' --args --explicitly-allowed-ports=6666"
  4. Use terminal to change the new file to be executable (chmod 755).

Note, I've not actually tried this, only outlining what's mentioned in the linked article.

  • The downside of this answer is that it results in a long series of "Google Chrome-bin wants to use your confidential information stored in ... in your keychain. Do you want to allow access to this item?"
    – yurkennis
    Mar 14, 2015 at 18:22

You must log in to answer this question.

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