阻止Applescript打开空的终端窗口

时间:2018-09-23 19:20:06

标签: applescript

我有一个Applescript,可在虚拟环境中打开一个终端窗口,并在虚拟环境中打开一个带有jupyter笔记本实例的窗口。

tell application "Terminal"

do script "cd /Users/myusername/myfolder && source myfolder_venv/bin/activate"
do script "cd /Users/myusername/myfolder && source myfolder_venv/bin/activate &&jupyter notebook"
activate
end tell
end run

它打开3个窗口,而不是2个终端窗口,但仅在终端应用程序未运行时才打开。否则,它将打开2个窗口。我的代码有问题吗?

1 个答案:

答案 0 :(得分:0)

只需将打开的窗口添加为位置

tell application "Terminal"

    do script "cd /Users/myusername/myfolder && source myfolder_venv/bin/activate" in window 1
    do script "cd /Users/myusername/myfolder && source myfolder_venv/bin/activate &&jupyter notebook" in window 1
    activate
end tell