
我設定了首選項,以便CTRL-D
關閉當前窗口,但如果我關閉最後一個/唯一的終端窗口,我希望終端應用程式退出。 iTerm2 可以做到這一點。終端可以嗎?
答案1
開啟 applescript 編輯器並貼上
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
set app to "Terminal"
repeat
if is_running(app) then
tell application app
set WindowNum to get window count
if WindowNum = 0 then
quit
end if
end tell
delay 5
end if
end repeat
然後保存腳本並雙擊運行它。