2012-10-30 34 views
18

我正在開發一個WebGL的驅動的應用,我想這樣的命令行啓動Chrome瀏覽器:如何更簡潔地從命令行啓動Chrome?

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

我只是不希望有型,在每一次。有沒有一種方法可以輕鬆將其轉換爲單字命令?如果它很重要,我正在使用一個mac。

回答

22

只是要一個別名在您的.bashrc或者.bash_profile中

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

,然後重新裝入你的shell。現在

exec $SHELL 

,每次你ogc(或任何你想將它命名)在你的終端,它會運行完整的命令open -a Google\ Chrome --args --disable-web-security

+0

我得到bash:export:'-args':不是有效的標識符 bash:export:'-disable-web-security':不是有效的標識符 當我嘗試運行exec $ SHELL – smuggledPancakes

+0

這應該是兩個破折號。這聽起來像是你以某種方式將它添加到了你的$ PATH中,你不需要這樣做。我在評論中添加的行是你需要的。請參閱我的dotfile回購中的示例。 https://github.com/kevinSuttle/dotfiles/blob/master/zsh/aliases.zsh只需將它們添加到.bashrc或.bash_profile的底部 –

-2

爲什麼不只是運行一個網絡服務器?打開一個終端,並在瀏覽器中鍵入

cd folder_with_html_and_assets 
python -m SimpleHTTPServer 

現在去http://localhost:8000當你做過去到終端,然後按Ctrl-C

這似乎比禁用您的安全和冒着越來越PWND好得多。

+3

npm包http-server也很方便。 'npm install http-server' – undefined

+0

沒有人會得到pwnd。他正在發展。也許快速搜索適合首先驗證你的陳述? http://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome – Metagrapher

+0

也許你應該研究爲什麼限制被添加到第一位。 – gman

8

這項工作對我來說:

  1. 修改在.bash_profile中
  2. 寫別名:
 
alias cchrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/tmp/chrome_dev_session" --disable-web-security' 
  • 運行
  • exec $SHELL
  • 隨着cchrome命令打開鉻的新視窗與停用網絡安全解決「 access-control-allow-origin「問題