我有一个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个窗口。我的代码有问题吗?
答案 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