以文件形式访问 xterm 的回滚缓冲区

Joh*_* Z. 8 xterm

是否有可能以某种方式将 xterm 的回滚缓冲区作为(只读)文件或字符设备访问?

核心问题(为了避免 x/y“问题”)是这样的:有时我刚刚执行的命令会创建非确定性输出,我想以某种方式使用它的输出,而无需预先考虑它. 现在,执行此操作的唯一方法(我知道)是使用鼠标将文本选择为主要选择。

Tho*_*key 6

您可以通过告诉 xterm 使用print-everything操作(通常不绑定到键)打印数据来做到这一点。

或者,在XTerm Control Sequences 中记录了一个转义序列:

CSI ? Pm i                                                                      
          Media Copy (MC), DEC-specific.                                        
            Ps = 1  -> Print line containing cursor.                            
            Ps = 4  -> Turn off autoprint mode.                                 
            Ps = 5  -> Turn on autoprint mode.                                  
            Ps = 1  0  -> Print composed display, ignores DECPEX.               
            Ps = 1  1  -> Print all pages.
Run Code Online (Sandbox Code Playgroud)

可以调用为

printf '\033[?11i'
Run Code Online (Sandbox Code Playgroud)

但是任何一种方法(写入文件)都需要配置一个printerCommand