使用Mac OSX“打开"使用-n标志打开URL的命令 [英] using Mac OSX "open" command to open URL with -n flag

查看:118
本文介绍了使用Mac OSX“打开"使用-n标志打开URL的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用-n标志时,我无法获得/usr/bin/open来打开浏览器到特定的URL.

I'm having trouble getting /usr/bin/open to open a browser to a specific URL when using the -n flag.

例如,这将起作用:

open -a "Google Chrome" "https://stackoverflow.com"

...成功打开所需的页面.但是,如果我的浏览器已经打开,它将在现有窗口中以选项卡形式打开.打开手册页上说应该用-n标志纠正,但是:

...successfully opening the desired page. However, if my browser is already open, it will open it in an existing window as a tab. The man page for open says this should be remedied with the -n flag, but:

open -n -a "Google Chrome" "https://stackoverflow.com"

......打开浏览器的新实例(窗口)到主页,而无需导航到所需的URL.

...opens a new instance (window) of my browser to the homepage without navigating to the desired URL.

我还尝试过在命令中的-n标志周围移动并与其他标志(例如-F)混淆.

I've also tried moving around the -n flag in the command and messing with other flags (such as -F).

环境:macOS Sierra 10.12.6

environment: macOS Sierra 10.12.6

更新:这是我尝试过的其他解决方案...

UPDATE: Here are some other solutions I've tried...

我尝试在URL之前添加--args.这使得它的行为类似于上面的第一个命令,基本上忽略了-n标志....

I've tried adding --args before the URL. This makes it behave like the first command above, essentially ignoring the -n flag....

open -n -a "Google Chrome" --args "https://stackoverflow.com"

...将打开所需的URL,但再次在选项卡中而不是新窗口中打开.

...will open the desired URL, but again in a tab and not a new window.

我尝试将--args选项设置为--new-window:

I've tried making '--new-window' an option for --args:

open -a "Google Chrome" --args '--new-window' "https://stackoverflow.com"

...这与-n标志的行为相同,即打开一个新窗口,但不向其传递URL.

...this behaves the same way as the -n flag, opening a new window but not passing it a URL.

我还尝试将URL放在--args之前:

I've also tried putting the URL before the --args:

open -n -a "Google Chrome" "https://stackoverflow.com" --args '--new-window'

...这就像我没有放置--args标志,在另一个选项卡中打开URL一样.

...this behaves as if I did not put the --args flag, opening the URL in another tab.

推荐答案

这适用于我的OSX El Capitan. --new-window是chrome参数,可以在此处

This works on my OSX El Capitan. The --new-window is a chrome argument, a list of which can be viewed here

open -n -a "Google Chrome" --args "--new-window" "https://stackoverflow.com"

这篇关于使用Mac OSX“打开"使用-n标志打开URL的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆