4

In screen there is a kill command, which kills the current window. This command can be sent even to a detached screen session by running:

screen -S SessionName -X kill

This works to kill the current window only. To kill any other window, it appears the only way is to first switch to that window and then kill it. The select command allows switching between windows in a screen session. Typing the following while attached to a screen session will select the window named foo.

^A:select foo

However, when not attached to the session, it appears the select command has no effect. Running the following two commands will kill the current window, rather than the window named foo (unless of course that is the active window).

screen -S SessionName -X select foo
screen -S SessionName -X kill

I have verified that this occurs even if I attach and detach from the session before attempting to select a window (a known workaround for some other screen quirks).

Huckle
  • 1,005
  • Did you omit quotes around "select foo"? – Celada Aug 31 '15 at 03:28
  • I've tried three variations in quoting. None of them work better than the others. "-X select foo" produces an error (expected). -X "select foo" produces no effect. -X select "foo" produces no effect. – Huckle Aug 31 '15 at 03:31

1 Answers1

3

You can try -p to select the window, numbered from 0, eg

screen -S SessionName -p 1 -X kill
meuh
  • 51,383
  • 1
    It seems that although the screen man page says that the kill command operates on the current window, it in fact requires the -p flag to select the window by title. – Huckle Sep 01 '15 at 04:11