How to disable notify on "screen -D -R"

I just had the same problem. In the latest version of screen, you can specify the -q flag to quiet screen, and keep it from showing.

The source shows

if (rflag && (rflag & 1) == 0 && !quietflag)

so I don't know where Gilles found that, or when it was changed.


Unfortunately, this behavior is hard-coded in the source: the same test is used to determine whether to emit the “New screen...” notification and to determine whether to attach to a running session. (In the screen 4.0.3 source, (rflag && (rflag & 1) == 0) in attacher.c and screen.crflag is 1 for -r plus 2 for each -R.)

If you're willing to recompile, the patch is trivial: remove the line that displays the message from screen.c.

You can make the message go away by typing something. If you don't want to type a key that will reach the application inside the screen window, you can type C-a ` or some other unbound key.

A simple workaround of sorts is to immediately detach the screen session (either with C-a d or with the detach command in the screenrc file; -m on the command line doesn't work for this when -R is also specified), then attach to it again (e.g. by running the same command again).

A really kludgy but fully automated workaround is to include the following lines in the screenrc file to skip messages initially and reenable them one second later:

msgwait 0
screen -t post_initialization 39 sh -c 'sleep 1; screen -X msgwait 5'

(39 is the highest possible window number, it's a compile-time option (MAXWIN).)

Note that both workarounds will hide any message screen chooses to display when it starts, not just the useless “New screen...” one.