bash 如何使用 URL“localhost:3000”从终端打开 Google Chrome?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28162697/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 12:15:49  来源:igfitidea点击:

How can I open Google Chrome from the terminal with the URL "localhost:3000"?

bashgoogle-chromegnome-terminal

提问by Zack

Whenever I try to open Google Chrome with the URL "localhost:3000" it messes up and simply opens a blank tab with no URL. After some testing I've figures out it is the ":" messing it up. This works:

每当我尝试使用 URL“localhost:3000”打开谷歌浏览器时,它都会出错,只是打开一个没有 URL 的空白选项卡。经过一些测试,我发现它是“:”搞砸了。这有效:

$ google-chrome www.gmail.com

but this does not work

但这不起作用

$ google-chrome localhost:3000

nor this

也不是这个

$ google-chrome "localhost:3000"

How can I open Google Chrome with this URL? I am using Ubuntu, bash script, and the gnome-terminal.

如何使用此 URL 打开 Google Chrome?我正在使用 Ubuntu、bash 脚本和 gnome 终端。

回答by Diego Torres Milano

Have you tried?

你有没有尝试过?

google-chrome http://localhost:3000

回答by Bexultan Myrzatayev

Got the following message:

收到以下消息:

zsh(or bash): command not found: google-chrome (or chromium-browser)

Solved my problem:

解决了我的问题:

open http://localhost:3000

{ I use Google Chrome as a default browser }

{ 我使用 Google Chrome 作为默认浏览器 }

回答by Damian Nikodem

I dont seem to have this problem.

我好像没有这个问题。

chromium-browser "http://localhost:8889"
chromium-browser "http://127.0.0.1:8889"

One quick suggestion would be to check to see if 127.0.0.1:3000 works (newer versions of ubuntu seem to have an issue resolving "localhost" instead of the numbered ip address.)

一个快速建议是检查 127.0.0.1:3000 是否有效(较新版本的 ubuntu 似乎在解析“localhost”而不是编号的 IP 地址时出现问题。)

回答by bmc

As stated beautifully by @Bexultan Myrzatayev, if google chrome is your default browser, simply

正如@Bexultan Myrzatayev 所说的那样,如果谷歌浏览器是您的默认浏览器,只需

open http://localhost:8000