"Open with" Chrome in the Command-Line - google-chrome

I want to open a html-file in Chrome by using the command-line without setting Google Chrome as default-browser. How can I do this, when I don't know the path where Chrome is installed?
I'm in the folder where the file is lying:
start page.html
Does there any "open with" Chrome function exist?
I need a solution, where I don't have to navigate to the path where chrome is lying.
Thanks!

This command will work.
For Google Chrome:
start chrome page.html
For Firefox
start firefox page.html
But start iexplore page.html will not work.

If you don't know the absolute path to the Chrome executable then you're reliant upon it being on the $PATH environment variable (or %PATH% on Windows). If Chrome has been installed normally, then it's probably on the path anyway.
You can try running chrome page.html on the command line. If the Chrome executable is on the path then this will open successfully and try to open page.html in a tab.
If the executable is not on the path then you will need to know the absolute path to it and run something like this instead: /absolute/path/to/chrome page.html or C:\Path\To\Chrome\chrome.exe page.html on Windows.

Related

Short-cut for moz-extension:// and chrome-extension://

background-image:url(chrome-extension://__MSG_##extension_id__/image.png);
For an extension that works for Firefox and Chrome, I just need to refer to a single image file in a CSS file.
chrome-extension:// works only for Chrome
moz-extension:// works only for Firefox
So I am stuck to create 2 separate CSS files just for single line of code.
Is there any short-cut for both of protocols?
Relative paths does not work for Chrome. Rather than searching in the root directory of the extension, Chrome searches the image file in web site root directory.

Can't open some html files in chrome (mac)

There are some HTML files (no pattern that I've figured out) that I can't open via the terminal, GUI or right clicking Open in Browser via Sublime Text 3.
The default browser to open the file is definitely set to Chrome. When I say to open the file in the browser it takes me to the Chrome window, but doesn't actually open the file I want.
I can open these files in Chrome itself via command + O and in Firefox or Safari by right clicking on the file and selecting them in the GUI.
It'd be great if Chrome would open files when I expect it to. I'd appreciate any help.
I had the same problem. Fixed it by running this in the terminal after closing Chrome:
open /Applications/Google\ Chrome.app --args --allow-file-access-from-files
The command line args can be viewed in Chrome by visiting chrome://version/
Chrome didn't load local files for me before running this command, but for some reason Chrome Canary did.
On your mac, right click the file and choose 'Open with' and then choose 'other'. Change the default to 'Safari' and then check the 'Always Open With' box. Click open. This should launch the file in Safari. Close the file in the browser and verify that double-clicking it will open it in Safari. Now do the same thing again except change the default back to Chrome.
You may have some security issue if you downloaded the *.html file from somewhere else.
None of the previous answers worked for me, but this one did:
On your Mac, choose Apple menu >> System Preferences >> click Security & Privacy >> click Privacy.
Select Files and Folders.
Please select the checkbox below the Nicepage application to access files and folders in that location.
Source: https://nicepage.com/doc/84207/access-denied-for-documents-folder-macos
Good luck, lads
it's a problem of extend attributes. If you use ls -l to see the attributes of your file, you will see some weird # .
ls -l xxxx.html
-rwxr-xr-x#
the solution is to use xattr.
xattr -c filename
xattr -rc directory
The solution provided by Xiaoou Wang works.
Explanation
I would like to extend this answer and provide below a different solution, which was not given yet.
Chrome (Mac) indeed does not open .html files that have the extended attribute com.apple.quarantine. This attribute is automatically applied on files that are downloaded from the web and are not Apple-authorized applications.
From the terminal, by typing
xattr 'your .html file name'
you can verify whether your .html file has the quarantine attribute set.
With xattr -c command you will remove all attributes, in case there are others set. If you want to only remove the quarantine attribute, type instead
xattr -d com.apple.quarantine 'your .html file name'
Alternative solution
This alternative solution might be even simpler for some people. With my Chrome (mac) I can open .html files by simply dragging the file from finder onto an already opened Chrome window, in spite of their com.apple.quarantine attribute. Important: It does not work if you drag the file onto Chrome's icon in the dock.
There might be an issue with your permissions settings. I tried everything and this is worked for me:
Open your Google Chrome Browser:
click Chrome,
open Preferences,
click Privacy and Security,
click Advanced (at the bottom),
scroll down to "Downloads",
under Location click the Change button.
Then choose where the file you are attempting to open is saved.
you can open this html file and try "command + option + I" to see the file content in the console window, if it's real html file there will be source code reveal. i don't think it can be the chrome's problem.

Is there a browser-sync option to open Google Chrome in incognito mode?

I've taken a look at the documentation but it's a little thin on what values are acceptable. Does anyone know if there's a value to open Google Chrome incognito and/or have a complete list (who knows I might want to open a project in IE/Edge one day).
I've tried:
browser: "google chrome -incognito"
browser: "-incognito"
browser: "incognito"
Not many more alternatives, I reckon.
Thanks in advance!
Chrome's command line switch is actually --incognito (two dashes), but I tried it in my browsersync Gulp task and that didn't work.
The workaround I'm using is to use a Chrome extension to switch my development domain name to incognito. It looks like there are a couple extensions that do that, I use Ghost Incognito:
https://chrome.google.com/webstore/detail/ghost-incognito/gedeaafllmnkkgbinfnleblcglamgebg?hl=en-US
in general, I created a shortcut to launch the browser in private mode. then in browser-sync settings added parameter:
browser: 'absolute path to shortcut'
Hurrah!

Sass source maps not auto-refreshing in Chrome

In Chrome Canary (Version 30.0.1570.0 canary) I've set up sass source maps as follows:
DevTools > Settings > General > Enable CSS source maps + Auto-reload generated CSS CHECKED!
DevTools > Settings > Added folder public
My folder structure looks as follows:
public
sass
_buttons.scss
style.scss
css
style.css
index.html (with link href=css/style.css)
In DevTools I can do inspect element and see that a style-rule comes from _buttons.scss. I can click the _buttons.scss and get the DevTools to display the scss source. I can modify the source in devtools and hit cmd+s and it's saved to disk and when switching to sublime, the file has been updated. BUT in Chrome the css is not automatically reloaded. I have to refresh the page manually to reload the css.
Sass version:
$ sass -v
$ Sass 3.3.0.alpha.149 (Bleeding Edge)
I watch with:
$ sass --scss --sourcemap --watch public/sass:public/css
Any body else having problems with the Auto-reload generated CSS in Chrome (Canary) ?
I've also tried Chrome "normal" (20.0...) and same problem there, no auto-reload.
Have you tried using Workspaces? That's what I use and it's working fine for me, and always has. A bunch of things have moved out of experiments recently, so maybe that's why it's not working?

How can I run Chrome without all browser's controls (tabs, address line, buttons)?

How can I run Chrome without all browser's controls (tabs, address line, buttons)?
only page-area loaded with specific URL
Thanks
Assuming you want to open a specific URL (let's say http://www.example.com), here are 3 options for your consideration. For all options, start by creating a shortcut to Chrome.exe, which you will edit by adding a flag/switch to the 'Target' property of the shortcut.
Open as an App - Use a 'Target' like this:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --app=http://www.example.com
This will open the web page in a generic Windows window, with no browser Chrome available although you can still access browser tools, e.g., pressing F12 to open Developer Tools.
Open Fullscreen - Use a 'Target' like this:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" http://www.example.com --start-fullscreen
This will open the web page in a Chrome window, which will start fullscreen unless there is another instance of Chrome already open, in which case the page will open in that instance. If you press F11, the browser will return to its normal view mode.
Open in Kiosk Mode - Use a 'Target' like this:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" http://www.example.com --kiosk
This will open the web page in a Chrome window, which will start in Kiosk mode unless there is another instance of Chrome already open, in which case the page will open in that instance. From my understanding, the only way to close this would be to press Alt+F4.
As mr_kazz explained, you can refer to http://www.chromium.org/developers/how-tos/run-chromium-with-flags to see which flags you can use to when launching a Chrome shortcut.
You'll need to start Chrome in "Kiosk mode"
Here is a tutorial for windows: http://think2loud.com/868-google-chrome-full-screen-kiosk-mode/
If you are building a more elaborate kiosk solution, you would put this command in a shell/bash script that would continuously run it (and wait for exit before doing it again). This was if your user pressed Alt+F4 it would just start it again.
http://www.chromium.org/developers/how-tos/run-chromium-with-flags
The above page links to a page with a huge list of arguments, maybe it can be achieved that way. I would also like to know how this can be done.
I currently use this for opening µTorrent server's webUI
chromium-browser --window-size=900,700 http://admin:#localhost:8080/gui/
Run it with the "--kiosk" switch:-
"C:\Program Files\Google\Chrome\Application\chrome.exe" --kiosk
or wherever else it might be installed.
You can open the webpage as an app. To find out how to do so, search a search engine for "open chrome webpage as app" and follow the instructions. I could paste the instructions here, but once you know how to search for it, it's pretty easy.