如何从终端打开Safari私人窗口?

问题描述 投票:0回答:1

为了在终端上通过Safari打开链接(例如Google),我写:

open -a safari https://google.com

如果要在私有窗口而不是标准窗口上打开此链接,是否有方法或标志可以从终端启用它?

bash safari terminal
1个回答
0
投票

此方法要求用户为系统事件启用辅助功能模式,这将向他们显示一个对话框。

您可以在终端中使用AppleScript来执行所需的操作:

osascript -e 'tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
click menu item "New Private Window" of menu "File" of menu bar 1
end tell
end tell'
© www.soinside.com 2019 - 2024. All rights reserved.