从屏幕手册页:
-X Send the specified command to a running screen session. You can
use the -d or -r option to tell screen to look only for attached
or detached screen sessions. Note that this command doesn't work
if the session is password protected.
基本上,运行
screen -X title mynewtitle
screen -X monitor on
如果终端未在屏幕内运行,则会出现静默错误:
notinscreen:~$ screen -X title mynewtitle
notinscreen:~$
即使在分离状态下,您也可以将命令发送到特定会话。给定一个名为“main”的屏幕会话:
$ screen -S main
[detach from screen session]
$ screen -ls
There is a screen on:
2073.main (Detached)
1 Socket in /tmp/uscreens/S-dbr.
..您可以将最后一个活动窗口的标题发送到blah
:
$ screen -x main -X title blah
..或特定窗口(名为oldwindow
在此示例中):
$ screen -x main -p oldwindow -X title blah
而不是使用-x main
您可以使用进程 ID(来自screen -ls
),也不要使用窗口名称(-p oldwindow
)您可以使用窗口号:
$ screen -x 2073 -p 0 -X title h
如果只有一个会话,则不必指定会话 PID 或名称。