从终端,在 safari 的新背景选项卡中打开本地 html 文件

from terminal, open a local html file in a new background tab in safari

目前,在终端中,我使用open sample.html命令在前台打开sample.html。

但我希望 safari 在后台打开一个选项卡并在该选项卡中打开 sample.html。

ps:

background可能有两种含义:

  1. “新标签页不在其他标签页前面”

  2. "safari 本身不在其他 ap 前面ps"。

这里我指的是意思1.

您是说要在打开 sample.html 后 re-open 另一个标签页吗?那么你可以 open sample.html && open foreground.html

在终端中:

osascript myapplescript.app my_url

在myapplescript.app中:

on openUrlInTheBackground(my_URL)
    tell application "Safari"
        tell window 1
            make new tab at end of tabs with properties {URL:my_URL}
        end tell
    end tell
end openUrlInTheBackground

on run argv
    set my_URL to (item 1 of argv)
    openUrlInTheBackground(my_URL)
end run