在GNU屏幕中使用滚轮

Jes*_*erE 246 gnu-screen mousewheel

如何设置GNU屏幕以允许鼠标滚轮在回滚缓冲区中滚动?我试图谷歌这个,但大多数点击如何允许屏幕内的应用程序使用滚轮.

Pis*_*tos 340

我相信你可以在这里添加这样的一行~/.screenrc:

termcapinfo xterm* ti@:te@
Run Code Online (Sandbox Code Playgroud)

其中"xterm*"是您当前TERM的全局匹配.要确认它有效,^ A ^ D要从屏幕上分离,然后screen -d -r重新连接,然后ls几次,然后尝试向后滚动.这个对我有用.


这个魔法是什么?好吧,让我们查阅手册页.

screen(1) 说:

termcapinfo term terminal-tweaks [window-tweaks]
  [..]
  The first argument specifies which terminal(s) should be affected by this
  definition. You can specify multiple terminal names by separating them with
  `|'s. Use `*' to match all terminals and `vt*' to match all terminals that
  begin with "vt".
  [..]
  Some examples:

      termcap xterm*  LP:hs@

  Informs screen that all terminals that begin with `xterm' have firm
  auto-margins that allow the last position on the screen to be updated (LP),
  but they don't really have a status line (no 'hs' -  append  `@'  to turn
  entries off).  Note that we assume `LP' for all terminal names that start
  with "vt", but only if you don't specify a termcap command for that terminal.
Run Code Online (Sandbox Code Playgroud)

来自termcap(5):

String capabilities
    [..]
    te   End program that uses cursor motion
    ti   Begin program that uses cursor motion
Run Code Online (Sandbox Code Playgroud)

  • 我遵循了皮斯托斯的建议,部分有效.正如他所描述的,我可以输入一些命令(产生足够的输出来滚动屏幕),然后使用鼠标滚轮向后滚动前面的行.事实上,我在KDE中通过Konsole使用屏幕(基本上是tabbed xterm),Konsole窗口的滚动条以相同的方式工作.但是有一个问题:如果你在屏幕的窗口之间切换(^ An,^ Ap),你的回滚缓冲区就会搞砸了.您切换到的任何窗口的内容都会被"隐藏"到您的回滚缓冲区中.这真的减少了它. (28认同)
  • 但是这会在命令历史中滚动.我想滚动输出缓冲区. (21认同)
  • 这使得能够在终端中滚动而不在屏幕会话中滚动.即如果您使用分割区域或切换窗口,您将无法在此区域中向后滚动,而是您将在终端输出中向后滚动并在分割区域或更改窗口之前查看输出. (16认同)
  • @JesperE:我也经历过滚动命令历史记录(我正在使用Ubuntu的GNOME终端).我通过转到编辑 - >配置文件首选项 - >滚动来修复它,并取消选中"使用按键在备用屏幕上滚动".请注意,我仍然需要使用Pistos的修复程序. (15认同)
  • 谢谢!我确认这也适用于腻子。 (2认同)
  • 除了在OS X Lion中工作之外,这也适用于Putty,iSSH和Prompt(由Panic提供).这一行应该存在于所有.screenrc文件中! (2认同)
  • 是的,完全同意g_daniel,这个解决方案不会在屏幕部分滚动,这正是我所期望的 (2认同)
  • 对于cygwin的薄荷,我不得不使用`terminfo xterm*ti =:te =`但它完美无缺. (2认同)

sle*_*ske 68

在屏幕中,您必须先进入"回滚模式"(或"复制模式")才能在回滚缓冲区中滚动:键组合Ctrl- a EscCtrl- a Ctrl- [.然后,您可以使用向上和向下键(或Ctrl- b,Ctrl- f移动页面)滚动历史记录.

在该模式下,如果鼠标滚轮适用于其他应用程序,它也应该可以正常工作.你结束了"回滚模式" Esc.

至于在没有先进入回滚模式的情况下滚动回滚缓冲区,如果不修改屏幕则可能无法实现.除了回滚模式之外,我从未听说过访问回滚缓冲区的方法.

  • 是的,我知道回滚模式.我希望我不必手动进入回滚模式才能使用鼠标.谢谢. (21认同)
  • "回滚模式"是一个非官方的术语恕我直言.:) __ Ctrl + a Esc__将进入__copy mode__; 这种模式一直被称为,因为它的主要目的是使来回复制文本成为可能.在复制模式下滚动鼠标滚轮的可能性(nb.对我来说不起作用)应该被视为一种"额外的噱头",但不是这种模式的主要目的. (4认同)
  • @syntaxerror:嗯,文档称之为“复制/回滚模式”,并提到“回滚缓冲区”(https://www.gnu.org/software/screen/manual/screen.html#Copy-and-Paste) ,所以我想我们都是对的:-)。无论如何,我在答案中添加了“复制模式”。 (3认同)

Tom*_* R. 24

Jon Z所指的优秀文章已不再可用,但我能够从Google缓存中获取纯文本版本.我将它保存在这里以防Google将来放弃它.MikaelStåldal的原始帖子是信用到期的信用.

-

如何在GNU Screen中使用鼠标滚轮

GNU Screen支持回滚,但默认情况下你必须使用笨键才能使用它.我希望能够使用Shift-PageUp,Shift-PageDown和鼠标滚轮进行滚动,就像在xterm中一样.

为此配置Screen并不容易,它涉及与终端仿真器的合作.但我终于设法实现了一个非常好的解决方案.将其添加到〜/ .Xresources文件中(您需要注销才能生效):

XTerm*saveLines: 0
XTerm*vt100.translations: #override \n\
  Ctrl <Btn4Down>: string(0x1b) string("[25S") \n\
  Lock Ctrl <Btn4Down>: string(0x1b) string("[25S") \n\
  Lock @Num_Lock Ctrl <Btn4Down>: string(0x1b) string("[25S") \n\
  @Num_Lock Ctrl <Btn4Down>: string(0x1b) string("[25S") \n\
  <Btn4Down>: string(0x1b) string("[5S") \n\
  Ctrl <Btn5Down>: string(0x1b) string("[25T") \n\
  Lock Ctrl <Btn5Down>: string(0x1b) string("[25T") \n\
  Lock @Num_Lock Ctrl <Btn5Down>: string(0x1b) string("[25T") \n\
  @Num_Lock Ctrl <Btn5Down>: string(0x1b) string("[25T") \n\
  <Btn5Down>: string(0x1b) string("[5T") \n\
  Shift <KeyPress> Prior: string(0x1b) string("[25S") \n\
  Shift <KeyPress> Next: string(0x1b) string("[25T") \n
Run Code Online (Sandbox Code Playgroud)

然后将其添加到〜/ .screenrc文件中:

defscrollback 1000

# Scroll up
bindkey -d "^[[5S" eval copy "stuff 5\025"
bindkey -m "^[[5S" stuff 5\025

# Scroll down
bindkey -d "^[[5T" eval copy "stuff 5\004"
bindkey -m "^[[5T" stuff 5\004

# Scroll up more
bindkey -d "^[[25S" eval copy "stuff \025"
bindkey -m "^[[25S" stuff \025

# Scroll down more
bindkey -d "^[[25T" eval copy "stuff \004"
bindkey -m "^[[25T" stuff \004
Run Code Online (Sandbox Code Playgroud)

这适用于xterm.我不确定它是否适用于其他终端仿真器.

请注意,这会禁用xterm中的正常滚动支持,您只能在使用Screen时滚动.您可能希望像这样启动xterm以始终使用Screen:

xterm -e screen
Run Code Online (Sandbox Code Playgroud)

  • 对我来说,Jon Z的答案中的原始链接仍然有效. (5认同)

Jes*_*sen 13

对于OS X(Snow Leopard),以下内容对我有用:

http://slaptijack.com/system-administration/mac-os-x-terminal-and-gnu-screen-scrollback/

简而言之,它涉及将以下内容添加到远程主机上的〜/ .screenrc(您正在运行的屏幕上):

defscrollback 5000
termcapinfo xterm* ti@:te@
Run Code Online (Sandbox Code Playgroud)


小智 11

并在GNU屏幕内的VIM中使用滚轮:

[的.vimrc]

set mouse=a             " hold shift to copy xterm
set ttymouse=xterm2     " necessary for gnu screen & mouse
Run Code Online (Sandbox Code Playgroud)


小智 11

以下内容在 Cygwin 和 Putty 中都对我有用:编辑 .screenrc 并添加

terminfo xterm* ti=:te=
Run Code Online (Sandbox Code Playgroud)


lem*_*eze 7

TERM变量设置为vt100而不是xterm在运行 screen 之前也有效。
我已经使用这个很长时间了,就像一个魅力。

将此添加到您的.bashrc

# make scrollbar / wheel scrolling work when running screen in gnome-terminal (or other)
if [ "$TERM" = "xterm" ]; then
  export TERM=vt100
fi
Run Code Online (Sandbox Code Playgroud)

——

作为参考,我.screenrc有这个(这个 AFAIK 不需要):

# Extend the vt100 desciption by some sequences.
termcap  vt100* ms:AL=\E[%dL:DL=\E[%dM:UP=\E[%dA:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC
terminfo vt100* ms:AL=\E[%p1%dL:DL=\E[%p1%dM:UP=\E[%p1%dA:DO=\E[%p1%dB:LE=\E[%p1%dD:RI=\E[%p1%dC
Run Code Online (Sandbox Code Playgroud)


Pet*_*tty 6

Ctrl+ a然后按[

终端的标题栏现在应该是复制模式.

现在箭头键和鼠标滚轮应该按预期工作.

要恢复正常,请按Esc键或按Enter键几次.


小智 5

使用“Ubuntu 16.04.2 LTS”时的解决方案如下:

A)。按照之前的答案指定更新$HOME/.screenrc :

termcapinfo xterm* ti@:te@
Run Code Online (Sandbox Code Playgroud)

b). 使用“设置”-“首选应用程序”,通过在下拉列表中选择“X 终端”将默认终端更改为 xterm。

一些多余的注释

  • 即使我将 termcapinfo 行更改为“*”而不是“xterm*”,其他终端(包括安装“lxterminal”)都不适合我。

  • 通过单击屏幕左上角的菜单按钮,您可以使用右下角的第三个图标打开“设置”对话框。