屏幕:如何打开备用屏幕? [英] screen: how to turn on alternate screen?

查看:179
本文介绍了屏幕:如何打开备用屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在终端中工作时,我看到了最后一个Shell命令执行输出的历史记录.如果我运行vim,我会看到全屏打开的文件.退出vim时,我可以再次看到最后一个shell命令的历史记录.

When I work in terminal, I see the history of the last shell commands execution output. If I run vim, I see the file I open full screen. When I exit vim, I can see the history of the last shell commands again.

但是,当我从屏幕上使用vim时.我从vim退出时看到的是刚刚编辑的文件的足迹,而不是最后一个shell命令的历史记录. 不过我想查看外壳的历史记录.

However, when I use vim from screen. I see the footprint of the file I was just editing on my exit from vim instead of the history of the last shell commands. I'd like to see the shell's history though.

我如何实现此行为?

我用过:

  • terminal.app和iterm2.app
  • 尝试将xterm切换到xterm-256color(在iterm2.app中)
  • 选中和取消选中在存在应用程序状态栏时将行保存到回滚"和在备用屏幕模式下将行保存到回滚"(在iterm2中)
  • 在.screenrc中添加termcapinfo xterm ti @:te @(尽管它应该是对付相反问题的解决方案,但为什么不尝试)
  • shing到linux机器并尝试在那里使用gnu-screen

到目前为止,我还没有得到想要的行为.

Up to now I didn't get the desired behaviour.

P.S.

我在Google上搜索了一下,看到了试图解决相反问题的人的评论:

I googled a bit and saw comments of people who try to solve the opposite problem:

你们中的许多人可能都知道基于控制台的程序的烦人行为,例如更少或退出后vi恢复屏幕,以便您刚刚在那里的文字消失了.

此行为背后的主要思想是程序是否使用备用屏幕保存shell历史记录的图片并在vim退出时显示它.因此,如果要解决相反的问题,他应该

The main idea behind this behaviour is whether programs use alternate screen to save a picture of the shell history and show it when vim exits. Thus if one wants to solve the opposite problem, he should

驱逐邪恶的备用屏幕

推荐答案

更新:我忘记了screen的功能,该功能默认情况下禁用备用屏幕支持.

UPDATE : I had forgotten about a feature of screen that disables alternate screen support by default.

altscreen on添加到您的$HOME/.screenrc以启用它.这可能就是您要做的全部; $TERM$TERMCAP$TERMINFO的所有混乱可能都是不必要的.无论如何,我将在此处保留其余答案.

Add altscreen on to your $HOME/.screenrc to enable it. This is probably all you have to do; all the messing about with $TERM, $TERMCAP, and $TERMINFO is probably unnecessary. I'll leave the rest of this answer here anyway.

我已经在自己的.screenrc中拥有了它,直到它让我忘了.

I've had this in my own .screenrc so long it slipped my mind.

要在当前会话中启用此功能,请键入您的screen转义字符(默认为 Cntrl-A ),然后键入:altscreen on Enter .

To enable this feature for the current session, type your screen escape character (Cntrl-A by default) followed by :altscreen on Enter.

否则,即使在terminfo或termcap中定义了转义序列,screen也不会对其进行响应.

Without this, screen won't respond to the escape sequences, even if they're defined in terminfo or termcap.

vim(和less,以及大多数其他基于curses的全屏程序)使用terminfo条目为您的终端定义的smcuprmcup字符串. (在较旧的termcap系统中,它们分别称为tite). smcup切换到备用屏幕,并且rmcup切换回到主屏幕.

vim (and less, and most other curses-based full-screen programs) use the smcup and rmcup strings defined by the terminfo entry for your terminal. (These are referred to as ti and te, respectively, in the older termcap system). smcup switches to the alternate screen, and rmcup switches back to the primary screen.

如果terminfo条目中没有这些字符串,则程序将无法执行这些操作.

If your terminfo entry doesn't have these strings, programs won't be able to do that.

默认情况下,screen命令将您的$TERM设置为"screen".显然,屏幕" terminfo条目没有smcuprmcup.

The screen command, by default, sets your $TERM to "screen". Apparently the "screen" terminfo entry doesn't have smcup and rmcup.

如果您想入侵terminfo条目,则可以修改"screen"的现有信息以添加smcuprmcup.您需要infocmp命令将terminfo转换为文本,并且需要tic将其转换回terminfo所使用的二进制格式.

If you feel like hacking terminfo entries, you can modify your existing information for "screen" to add smcup and rmcup. You'll need the infocmp command to convert your terminfo to a text, and tic to convert it back to the binary form used by terminfo.

一个更简单的解决方案是将$TERM环境变量设置为调用screen命令之前的环境变量.如今,几乎所有终端仿真器都基于旧的DEC VT100,因此它们应该具有足够的兼容性.

A simpler solution is to set your $TERM environment variable to whatever it was before you invoked the screen command. Almost all terminal emulators these days are based on the old DEC VT100, so they should be sufficiently compatible.

例如,在我的系统上,登录时,我有TERM=xterm; MacOS上可能还有其他内容.在screen会话中,默认情况下,我将拥有:

On my system, for example, when I login I have TERM=xterm; it's likely something else on MacOS. Within a screen session, by default, I'd have:

 $ echo $TERM
 screen

我可以这样将其更改为xterm:

I could change it to xterm like this:

$ export TERM=xterm

(同样,将"xterm"替换为系统上的任何$TERM.)

(Again, replace "xterm" by whatever $TERM is on your system.)

您也可以添加

term xterm

到您的$HOME/.screenrc.实际上,screen有许多选项可用于调整termcap/terminfo设置. man screen并搜索"terminfo"以获取详细信息.

to your $HOME/.screenrc. In fact screen has a number of options for tweaking your termcap/terminfo settings; man screen and search for "terminfo" for the gory details.

这篇关于屏幕:如何打开备用屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆