本文共 2040 字,大约阅读时间需要 6 分钟。
screen是一个full-screen窗口管理器,用于管理多个交互式的shell通过一个物理的终端。每个虚拟终端提供了DES VT100终端功能,附加多中ISO 4629(ECMA 48, ANSI X3.64ISO 2022标准)控制功能(例如:insert/delete 行和支持多字节设定)。这里有一个滚动历史buff框为每个虚拟终端而且复制粘贴机制允许你去拷贝文本区域在这些虚拟终端之间。
这段文字是直接翻译的man中来做参考。里面读出来的信息就是说,其实这个screen是利用一个物理终端来管理多个虚拟终端。而且他是一个全屏的命令。为啥我们要使用这个呢。这个疑问我刚刚开始的时候也有。在使用了之后才觉得这个东西是个神器。之前我去连接服务器的时候,大都是通过xshell去连接。当然有些事用来打开vim。有些窗口是用于去makefile,有些窗口是用于做做console方式运行服务器。这样相安无事的也的确很好。但是,如果本来我在家里通过远程去调试了服务器,事情没有做完现在要出去有事,或者家里网络断掉了,就造成已经打开的vim、makefile、console方式的服务器session全部关闭。这些session上的全部东西都被终结了。但是有了screen就不同了。我可以将vim,make,console svr都放到我一个screen的虚拟容器中。当掉线,或者我自己想暂时的退出的时候,只需要按一下ctrl+a+d。今后有网络的时候,将可以重新唤起之前的编辑环境回来。我们可以通过下面的命令来创建一个名字为learn的screen
$screen -S learn$screen -list
这个是man里面提供的帮助信息。
-S sessionname When creating a new session, this option can be used to specify a meaningful name for the session. This name identifies the session for "screen -list" and "screen -r" actions. It substitutes the default [tty.host] suffix. -list [match] does not start screen, but prints a list of pid.tty.host strings identifying your screen sessions. Sessions marked `detached' can be resumed with "screen -r". Those marked `attached' are running and have a controlling terminal. If the session runs in multiuser mode, it is marked `multi'. Sessions marked as `unreachable' either live on a different host or are `dead'. An unreachable session is considered dead, when its name matches either the name of the local host, or the specified parameter, if any. See the -r flag for a description how to construct matches. Sessions marked as `dead' should be thoroughly checked and removed. Ask your system administrator if you are not sure. Remove sessions with the -wipe option.
创建新的一个窗口
ctrl + a + c
在screen容器中循环的切换窗口列表
ctrl+a+space
在screen容器中切换最近的两个窗
ctrl+a+a
向前切换一个窗口
ctrl+a+p
向后切换一个窗口
ctrl+a+n
直接定位窗口
ctrl+a+[0-9]
挂起
ctrl+a+d
唤起
screent -r learn
如果你发现ctrl+a这一系列的命名对你无效的时候,绝逼是你没有在一个screen里面。这点切记。
转载地址:http://nbfmf.baihongyu.com/