Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

Thank you.

share|improve this question

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.

share|improve this 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 '11 at 22:38

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 chrome_bin). Make a blank text file in the folder with the same name (Google Chrome) as the original file and paste in the following script:

#!/usr/bin/bash

./chrome_bin --args --explicitly-allowed-ports=6666

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

share|improve this answer

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:

    #!/bin/sh

    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.

share|improve this answer

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.