什么是GNU屏幕?太棒了!
嗯,一个稍微有用的答案是:它允许您在一个终端中运行多个控制台应用程序或命令。有点像一个选项卡式终端模拟器。事实上,这正是它的本质(只是没有使用常规的GUI工具包)
为什么这么棒?简单地说,您可以在屏幕会话中运行一个程序(运行<code>screen</code>,它运行默认的shell,运行<code<screen myapp</code〕,它在会话中运行myapp),点击<kbd>ctrl</kbd>+<kbd>a</kbd>(屏幕控制序列),然后按<kbd〉d</kbd>(<kbd<ctrl<-kbd>+d</kkd>)进行分离。
该程序保持在后台运行,但,与执行mycmd&
它在控制台IRC客户端中非常受欢迎——您可以运行(比如)<code>屏幕irssi</code>,并从任何可以SSH的地方重新连接会话。
一些有用的命令:
- ctrl+a, c to make a new virtual terminal (or "window") in the session
- ctrl+a, n and ctrl+a, p to cycle through multiple windows
- ctrl+a, 1 to select window 1, ctrl+a, 4 to select window 4 and so on
- ctrl+a, ctrl+a to flick between the last two active windows
- ctrl+a, shift+a (upper-case a) allows you to rename the current window
- ctrl+a, ` (for me, that s shift+2 - the quote mark) lists windows, you can use the arrows and select one. Also useful with the "tab bar" setting I ll list in a second
我偶然发现了其他一些有用的东西:
- Use the
-U
flag when you launch screen so it supports Unicode (for example, screen -xU
)
- The
-x
flag allows you to reattach the same session multiple times. (-r
disconnects existing connections)
- You can do interesting stuff with the status bar. I have my setup to display
[ hostname ][ 0-$ bash (1*$ irssi) ][16/09 9:32]
(Running on hostname, it has two windows. This is set by the hardstatus lines in my .screenrc (at the end of the answer)
startup_message off
vbell off
hardstatus alwayslastline
hardstatus string %{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}]%{=y C}[%d/%m %c]%{W}