MacOS – Hold Terminal open

macosterminal

Sometimes I'm working on something in the terminal, and then go away. When I come back, I want to resume what I was working on, but sometimes I forget, and hit commandQ, which closes all the terminal windows automatically, no questions asked.

Is there a command that can "hold" a Terminal tab so that I don't accidentally close what I was doing?

As an example, what I want can be hackishly accomplished by running sleep LARGE_NUMBER in the tab I want to keep open.

Then if I accidentally hit commandQ, it won't close directly, and rather present me with the following, which gives me an opportunity to cancel and resume what I was doing:

Best Answer

There's an option to show a dialog before closing any tab in the preferences:

enter image description here

Translating the screenshot to english is left as an exercise to the reader.