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 command-Q, 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 command-Q, 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:

2 Answers 2


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.

  • Right, but most of the time I don't want it to ask... Although I guess this could work for some.
    – houbysoft
    Jun 26, 2012 at 20:02
  • 1
    @patrix , you are my hero :) Not all answers have to be so serious.
    – ephsmith
    Jun 26, 2012 at 20:03
  • @houbysoft, this is probably your best approach. A gentle confirmation dialog isn't that bad given your propensity toward command-q.
    – ephsmith
    Jun 26, 2012 at 20:06
  • 2
    @patrix I'm tempted to revert the answer so the website isn't quite so monoglot and humourless.
    – Cajunluke
    Jun 26, 2012 at 20:17
  • 1
    :-) I changed it back due to popular demand...
    – nohillside
    Jun 27, 2012 at 18:27

This can be solved by running cat, which will make it wait for input forever.

For faster usage, an alias can be defined in ~/.bashrc:

alias h="cat"
  • Runnin top should also work.
    – lhf
    Jun 26, 2012 at 20:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .