什么是 GNU 屏幕?

发布于 2024-07-04 01:22:40 字数 18 浏览 5 评论 0原文

什么是 GNU 屏幕?

What is GNU Screen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枯叶蝶 2024-07-11 01:22:41

什么是GNU Screen? 伟大的!

嗯,一个稍微有用的答案:它允许您在一个终端中运行多个控制台应用程序或命令。 有点像选项卡式终端模拟器。 事实上,这正是它的本质(只是没有使用常规 GUI 工具包完成)

为什么它如此出色? 很简单,您可以在 screen 会话中运行程序(运行 screen 它会运行您的默认 shell,运行 screen myapp 它会在会话中运行 myapp),点击 ctrl+a(屏幕控制序列),然后按 dctrl+a ,d) 分离。

该程序在后台继续运行,但是,与 mycmd & 不同,您可以运行 screen -r 来重新附加会话以及所有内容是你离开时的样子。 您可以将输入发送到命令,如果它是一个curses UI,一切仍然像“真实”终端一样工作。

它在控制台 IRC 客户端中非常流行 - 您可以运行(例如)screen irssi 并从可以通过 SSH 的任何地方重新附加会话。

一些有用的命令:

  • ctrl+ac 在会话中创建一个新的虚拟终端(或“窗口”)
  • ctrl +anctrl+ap 至循环多个窗口
  • ctrl+a1选择窗口1,ctrl+a、4 选择窗口 4 等
  • ctrl+actrl+a< /kbd> 在最后两个活动窗口之间滑动
  • ctrl+ashift+a(大写) a) 允许您重命名当前窗口
  • ctrl+a, ` (对我来说,就是 shift+< kbd>2 - 引号)列出窗口,您可以使用箭头并选择一个。 对于“选项卡栏”设置也很有用,我将在稍后列出

我偶然发现的其他一些有用的东西:

  • 启动屏幕时使用 -U 标志,以便它支持 Unicode(例如, screen -xU)
  • -x 标志允许您多次重新附加同一会话。 (-r 断开现有连接)
  • 您可以使用状态栏做一些有趣的事情。 我的设置是显示 [ hostname ][ 0-$ bash (1*$ irssi) ][16/09 9:32] (在主机名上运行,它有两个窗口。这是由我的 .screenrc 中的 Hardstatus 行(在答案的末尾)
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}'

What is GNU Screen? Great!

Erm, a slightly more useful answer: it allows you to run multiple console applications, or commands, in one terminal. Kind of like a tabbed terminal emulator. In fact, that's exactly what it is (just not done with the regular GUI toolkits)

Why is it so great? Simple, you can run a program in a screen session (Run screen and it runs your default shell, run screen myapp and it runs myapp in the session), hit ctrl+a (the screen control sequence) and then press d (ctrl+a,d) to detach.

The program keeps running in the background, but, unlike doing mycmd &, you can run screen -r to reattach the session, and everything is as you left it. You can send input to the command, if it's a curses UI, everything still works just like if it were a "real" terminal.

It's very popular with console IRC clients - you can run (say) screen irssi and reattach the session from anywhere you can SSH from.

A few useful commands:

  • 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

A few other useful things I've stumbled across:

  • 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}'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文