Skip to content

macos – How to stop command-W from closing iTerm2 when it’s active instead of the Python plots I’m intending to close?

  • by
Spread the love


I regularly run Python scripts from an iTerm2 command window, and the scripts usually generate several plots. I have an IDE open as well.

From time to time I end up accidentally closing the iTerm window with a command-W instead of closing Python’s matplotlib windows that I’m targeting.

If I’ve had too much coffee I may end up doing this a few times in a row.

I don’t see any useful function that closing an iTerm2 window with command-W would ever serve me, so I’d like to inhibit it’s closing power on iTerm2.

Under iTerm2/Preferences/Closing I see some options to require confirmation upon command-Q, but there seems to be nothing that addresses command-W under any menu item.

Question: How can I stop command-W from closing iTerm2 when it’s active instead of the Python plots I’m intending to close?

Alternatively, if there’s a way to get the closed window back somehow (since it doesn’t seem to be gone; if the script used a lot of memory it remains allocated even when the window is closed) that would certainly at least help.

Leave a Reply

Your email address will not be published. Required fields are marked *