0

How to open an URL with Google Chrome from command-line with a specific profile?

I've so far come up with the following but the --args --profile-directory="Profile 22" part does not seem to pass the argument to Google Chrome:

open -a 'Google Chrome' https://www.bing.com --args --profile-directory="Profile 22"

The -g option is intended to not bring the Google Chrome window immediately to the foreground. C.f. the documentation for open:

-g  Do not bring the application to the foreground.

The following does work, but I'm trying to avoid using specific full path for Google Chrome:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --profile-directory="Profile 22" 'https://www.bing.com'

1 Answer 1

4

You can use. e.g.:

open -na 'Google Chrome' --args --profile-directory="Profile 22" 'https://www.bing.com'

However, not with the -g option.

The -n option is used to ensure opening the given profile if another profile already has a window open.

2
  • Is it possible to do this without bringing the activated window into focus/front?
    – Meng Lu
    Dec 26, 2021 at 9:34
  • Or perhaps immediately switch the focus back to the tab that was in focus after opening the new tab?
    – Meng Lu
    Jan 21 at 18:57

You must log in to answer this question.

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