How can I open a non-http URL (Chrome extension) in Google Chrome from the terminal in OS X?

I'm trying to add a shortcut to open Chrome with a non-http url from a bash script. This is what I've got:

/usr/bin/open -a "/Applications/Google Chrome.app" 'chrome-extension://hgmloofddfasdfasdffgcellkdadsfadsfbjeloo/RestClient.html#RequestPlace:saved/2'   

Since the argument doesn't start with "http" Chrome tries to open it as a file, which of course doesn't exist, nor is it what I want.

Is there a way to make Chrome treat that as a url?

Edit:

@mjb - that's almost working. Thank you.

The extension (Advanced Rest Client) is installed locally. However, there's something different about loading it as a file and loading it with "chrome-extension://". When I load it as a file, I don't get the data (my rest requests) that has been saved as part of the app. Without that, it's useless.

Here's what I'm running from bash:

/usr/bin/open -a /Applications/Google\ Chrome.app /Users/me/Library/Application\ Support/Google/Chrome/Default/Extensions/hgmloofdphfgcellkdfbfbjeloo/3.1.7_0/RestClient.html

It loads my app, and it comes up - just without my context/data. When I click the extension in Chrome, it uses the following url:

chrome-extension://hgmloofdphfgcellkdfbfbjeloo/RestClient.html#RequestPlace:saved/2

Note that the hash on the end makes no difference. The UUID is the same as the local directory.

I also tried loading it with:

https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffgcellkdfbfbjeloo/RestClient.html

That just brings up the Chrome Web Store page for this app.

The data I want to use does appear to be in the database file for this extension, which is in:

/Users/me/Library/Application Support/Google/Chrome/Default/databases/chrome-extension_extension_hgmloofddffdnphfgcellkdfbfbjeloo_0/5

Any ideas?


I believe open attempts to process the passed URL before passing it on to Chrome. Since it doesn't recognize the 'chrome-extension' scheme, it interprets it as a relative file path.

Instead, you can use AppleScript to accomplish this.

osascript <<EOD
set theURL to "chrome-extension://nmmhkkegccagdldgiimedpiccmgmieda/html/craw_window.html"
tell application "Google Chrome"
 if windows = {} then
  make new window
  set URL of (active tab of window 1) to theURL
 else
  make new tab at the end of window 1 with properties {URL:theURL}
 end if
 activate
end tell
EOD

Note that the above code is actually AppleScript wrapped in a bash heredoc and passed to the osascript command, so you can drop it right into the terminal or a shell script.


Whether you mean to or not, you're telling Chrome to open a local file.

If you're trying to navigate to an extension online, it has an https address, like Evernote Web Clipper:

https://chrome.google.com/webstore/detail/evernote-web-clipper/pioclpoplcdbaefihamjohnefbikjilc?hl=en-US

If your goal is to load a local extension, you have to give the full path to the extension, not the relative path. By default, you can find them here:

/Users/<USER>/Library/Application Support/Google/Chrome/Default/Extensions

But these do not have a local chrome-extension:// URL. If I understand correctly, you would want to do:

$ /usr/bin/open -a "/Applications/Google Chrome.app" "/Users/<USER>/Library/Application Support/Google/Chrome/Default/Extensions/<EXTENSION-ID>"

Where <USER> is your user and <EXTENSION-ID> is the unique identifier of your extension. That will bring Chrome into a directory navigation mode where you can then load whatever file you're after from there.

If this doesn't help, it'd be good to clarify what your goal in the original question.