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

标签 macos shell google-chrome applescript

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

open -n /Applications/Google\ Chrome.app --args --enable-speech-input

open -n /Applications/Google\ Chrome.app www.google.com

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

open -n /Applications/Google\ Chrome.app --args --enable-speech-input "www.google.com"

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

最佳答案

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

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-speech-input www.google.com

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

(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-speech-input www.google.com) &

关于macos - 如何在 mac osx 上使用 shell 脚本中的标志和 URL 启动 Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27359804/

相关文章:

从第二个 "\n"和其余部分中删除字符串中的行返回(不要删除第一个)

C - 编译程序时出现多个警告 "pointer is missing a nullability type specifier",我该怎么办?

linux - Bash 认为输入不正确?

shell - 错误 : modifier in $ (/)

java - Watson 文本转语音功能在 Chrome 中无法运行

javascript - CKEditor 不适用于 MAC chrome 和 MAC Safari

python - Socket.py权限错误

bash - 命令运行时执行 bash 循环

performance - 网页的堆大小被认为太大了?

html - 我怎样才能修复它在 chrome 中的样子