macos Firefox openURL:OSX 命令行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10866628/
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-10-21 09:13:23  来源:igfitidea点击:

Firefox openURL : OSX Command Line

macosfirefox

提问by LaC

Context

语境

I want to open a Firefox browser from the command line and have it go to youtube.com

我想从命令行打开 Firefox 浏览器并将其转到 youtube.com

I have tried: open /Applications/Firefox.app --args -remote "openURL(www.youtube.com, new-tab)"

我试过: open /Applications/Firefox.app --args -remote "openURL(www.youtube.com, new-tab)"

It successfully opens a Firefox, but does not navigate to youtube.com

它成功打开了 Firefox,但无法导航到 youtube.com

Question:

问题:

How do I fix this?

我该如何解决?

回答by LaC

open -a Firefox 'http://www.youtube.com/'

open -a Firefox 'http://www.youtube.com/'

回答by Tim Pote

If firefox is your default browser you can simply use: open 'http://www.youtube.com'

如果 Firefox 是您的默认浏览器,您可以简单地使用: open 'http://www.youtube.com'

回答by david

Maybe you can append two aliases, edit ~/.bash_profile, append code below:

也许你可以附加两个别名,编辑 ~/.bash_profile,在下面附加代码:

open_by_browser(){ open -a  }
alias firefox='open_by_browser firefox'
alias chrome='open_by_browser "Google Chrome"'

then you can open html file by Firefox

然后你就可以用 Firefox 打开 html 文件了

firefox xxx.html

or by Chrome

或通过 Chrome

chrome xxx.html

回答by Hassan

The others' answers work by the way, but another way you can do it is:

其他人的答案顺便说一下,但另一种方法是:

/Applications/Firefox.app/Contents/MacOS/firefox "youtube.com"

回答by mbokil

You can open Firefox to a specific url and pass params if you want. Note: kiosk mode is an example only supported in Firefox 71 beta.

如果需要,您可以打开 Firefox 到特定的 url 并传递参数。注意:信息亭模式是仅在 Firefox 71 beta 中支持的示例。

open -a /Applications/Firefox.app "https://stackoverflow.com" --args --kiosk