I have my preferences set so that CTRL-D closes my current window, but I'd like the Terminal application to quit if I close my last/only terminal window. iTerm2 can do this. Can Terminal do it?


open applescript editor and paste in

on is_running(appName)
    tell application "System Events" to (name of processes) contains appName
end is_running

set app to "Terminal"

    if is_running(app) then
        tell application app
            set WindowNum to get window count
            if WindowNum = 0 then
            end if
        end tell
        delay 5
    end if
end repeat

Then save the script and run it by double-clicking it.

  • You can get this to work for most programs. – Kamin Pallaghy Dec 17 '15 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.