用vim读取gnu屏幕日志 [英] Reading gnu-screen logs with vim

查看:64
本文介绍了用vim读取gnu屏幕日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我发现了一个很棒的终端多路复用工具,称为gnu-screen.我完全满意.但是我遇到了一个我想改善的不便之处.

Recently I've discovered a wonderful terminal multiplexing tool called gnu-screen. I'm satisfied with it completely. But I've encountered one inconvenience I'd like to improve.

'C-a H'命令可将所有屏幕记录到名为"screenlog.*"的日志文件中.但是以奇怪的方式编码控制字符.例如,如果您使用较少"打开日志文件,则可能会看到一些隐含字符,并且日志文件不可读.您必须运行"less -r"或"less --raw-control-chars",这有助于正确编码那些控制字符.

'C-a H' command makes screen log everything to a log file called named 'screenlog.*'. But encodes control characters in a weird way. For example if you open the log file with 'less' you might see some cryptic characters and the log file is unreadable. You have to run 'less -r' or 'less --raw-control-chars' which helps to encode those control characters correctly.

到目前为止,一切都很好.但是,如果您要编辑日志或使用vim读取日志,则控制字符也会遇到相同的问题.

So far so good. But if you want to edit the log or read it with vim then you encounter the same problem with control characters.

我已经搜索了这个问题,抬头看着SO,但是我不知所措,因为关于Vim和屏幕的信息太多了.不幸的是我还没有找到解决方案.

I've googled this problem and looked up at SO but I've been overwhelmed because there's so much info about vim and screen. Unfortunately I haven't found the solution yet.

也许您知道此问题的解决方案或一些解决方法.

Perhaps you know the solution for this problem or some workaround.

UPD 感谢FrédéricHamidi的评论,我发现这些字符是字体颜色等的末尾转义序列.Vim作为编辑器看到它们,默认情况下对其进行编辑.Frédéric建议的插件告诉vim解释它们.

UPD Thanks to Frédéric Hamidi's comment I discovered those characters are the terminal escape sequences of font color, etc. Vim as an editor sees them and by default edits them. The plugin Frédéric suggested tells vim to interpret them.

推荐答案

在此处提供答案并最终将此问题标记为:

To provide an answer here and finally mark this fixed: The AnsiEsc plugin adds syntax highlighting for ANSI color sequences. So instead of seeing ^[[30m; the following text will be highlighting in the corresponding color, just like when using less --raw-control-chars.

这篇关于用vim读取gnu屏幕日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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