33

I am developing a WebGL driven application and I want to launch chrome like this from the command line:

open -a Google\ Chrome --args --disable-web-security

I just don't want to have to type that in every single time. Is there a way to easily turn that into a one word command? I am using a mac if it matters.

Imanou Petit
  • 89,880
  • 29
  • 256
  • 218
smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113

4 Answers4

33

Just make an alias in your .bashrc or .bash_profile

alias ogc='open -a Google\ Chrome --args --disable-web-security'

And then reload your shell.

exec $SHELL

Now, every time you type ogc (or whatever you want to call it) in your terminal, it will run the full command open -a Google\ Chrome --args --disable-web-security

Kevin Suttle
  • 8,358
  • 3
  • 33
  • 37
  • I get bash: export: `–args': not a valid identifier bash: export: `–disable-web-security': not a valid identifier when I try to run exec $SHELL – smuggledPancakes Nov 03 '12 at 19:12
  • That should be two dashes. It also sounds like you added it to your $PATH somehow, which you don't need to do. The line I added in the comment is all you need. See the examples in my dotfile repo. https://github.com/kevinSuttle/dotfiles/blob/master/zsh/aliases.zsh Just add them to the bottom of your .bashrc or .bash_profile – Kevin Suttle Nov 04 '12 at 04:18
  • 2
    I just used your tip to open Chrome Canary 73 in Mojave dark mode: `open -a Google\ Chrome\ Canary --args --force-dark-mode` – Steve Dec 13 '18 at 22:48
  • 1
    that just moves the focus to chrome if chrome is already open – SuperUberDuper Jun 18 '20 at 07:23
10

This work for me:

  1. Modify the .bash_profile
  2. Write this alias:
alias cchrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/tmp/chrome_dev_session" --disable-web-security'
  1. Run
exec $SHELL
  1. With the cchrome command open a new windows of chrome with the disable web security to solve the "access-control-allow-origin" problem
5

The Easiest way to Launch Chrome with flags in MAC using terminal is :

'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' --disable-features=CrossSiteDocumentBlockingAlways,CrossSiteDocumentBlockingIfIsolating

Any filter can come after -- in the above code --disable-features=CrossSiteDocumentBlockingAlways,CrossSiteDocumentBlockingIfIsolating is just an example.

Note: Make sure to close all instances of Chrome before running it.

vivek agarwal
  • 435
  • 4
  • 6
-5

Why not just run a webserver? Open a terminal and type

cd folder_with_html_and_assets
python -m SimpleHTTPServer

Now in your browser to go http://localhost:8000 When your done go to the terminal and press Ctrl-C

That seems much better than disabling your security and risking getting pwnd.

gman
  • 100,619
  • 31
  • 269
  • 393
  • 3
    the npm package http-server is also very convenient. `npm install http-server` – undefined Dec 23 '13 at 20:59
  • No one is getting pwnd. He's doing development. Maybe a quick search would be appropriate to verify your statements first? http://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome – Metagrapher Jul 19 '15 at 18:58
  • Maybe you should research why that restriction was added in the first place. – gman Jul 19 '15 at 21:31