如何在 mac osx 上使用 shell 脚本中的标志和 URL 启动 Chrome

Vij*_*ith 2 macos shell applescript google-chrome

当我从 shell 脚本启动 Chrome 时,我想使用一些 URL 和启用标志来启动 Chrome。我已尝试以下操作,但只能实现启用标志或启动 URL。不是两个都在一起。

open -n /Applications/Google\ Chrome.app --args --enable-speech-input
Run Code Online (Sandbox Code Playgroud)

或者

open -n /Applications/Google\ Chrome.app www.google.com
Run Code Online (Sandbox Code Playgroud)

上述两个命令都正确运行,但是当我尝试同时执行这两个命令时,如下所示:

open -n /Applications/Google\ Chrome.app --args --enable-speech-input "www.google.com"
Run Code Online (Sandbox Code Playgroud)

它失败。我尝试使用引号,但这不起作用。

Dar*_*ehe 5

不使用open,而是直接从脚本运行 Chrome 可执行文件:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-speech-input www.google.com
Run Code Online (Sandbox Code Playgroud)

如果打开 Chrome 后要运行更多命令,您可以通过在&命令后面添加字符来在后台打开 Chrome(注意命令现在位于括号中):

(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-speech-input www.google.com) &
Run Code Online (Sandbox Code Playgroud)