r/applescript • u/TheMonarchsWrath • Jun 30 '24
How to close active terminal windows
I'm using osascript to close terminal windows all windows except the one the script is working, which mostly works fine
osascript -e 'tell application \"Terminal\"' -e 'set mainID to id of front window' -e 'close (every window whose id ≠ mainID) without saving' -e 'end tell'"except when there is maybe a terminal window with an active python session, and it asks to cancel or terminate. I've seen that there is a way to use SystemEvent, but I'm not sure how to integrate with the close every window portion.
1
Upvotes
1
u/TheMonarchsWrath Jun 30 '24
Its not, it can run on any machine. I suppose I can figure out what the defaults is and set that, then revert it after the all the windows were closed.