Is there any way to make GNU Screen not close if I end all its subprocesses? Ideally, it would create a new window running a shell if I accidentally closed the last window.


Assuming you're using bash and accidentally closes the shell with Ctrl-D, you can

export IGNOREEOF=1

This will give you a warning and require you to press Ctrl-D twice, or type exit instead.

| improve this answer | |
  • 3
    Thanks! I added this to my ~/.screenrc: setenv IGNOREEOF 10 / screen -t main bash / unsetenv IGNOREEOF – P-Nuts Jun 24 '11 at 15:40
  • 1
    +1 because there's no part of my life that hasn't been improved after learning that! – EightBitTony Jun 24 '11 at 16:09
  • 1
    I did some more investigation and if you search for "Suddenly the Dungeon collapses!!" in attacher.c, it should be possible to change the code to spawn a new window somehow, instead of shutting down the whole thing. The source is just one quick git clone away: git://git.sv.gnu.org/screen.git – Alexander Jun 24 '11 at 16:47
  • 1
    Haha! I don't really want to go to the effort of maintaining my own patch to Screen, but thanks for reminding me of the Nethack option. (Though I was more of an Angband man myself...) – P-Nuts Jun 24 '11 at 22:18
  • Accidental terminal cloures was a huge annoyance for me. Added set -o ignoreeof to ~/.bashrc; works in konsole | xfce4-terminal | ... – Victoria Stuart Apr 19 '18 at 20:16

I don't know of a way to do that specifically, but I find zombie {} useful; when I close a window, it prompts me to hit { or } to close or reopen it, respectively.

| improve this answer | |
  • can this be used without having a screenrc? – Janus Troelsen Jul 18 '15 at 9:04

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.