Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Is there a way of getting current xterm buffer?
- X-seq: zsh-users 29271
- From: Grant Taylor <gtaylor@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Is there a way of getting current xterm buffer?
- Date: Tue, 19 Sep 2023 22:05:41 -0500
- Archived-at: <https://zsh.org/users/29271>
- In-reply-to: <CAKc7PVAWcQ7HokZAF0LzoLciY3_cDSp0wzTkP=25ov+waKYmig@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAKc7PVDmdYC+7k5gLTabqmm=iSQg0W7oMLN3R=Na4W=Qmaz-8w@mail.gmail.com> <ee1f04c1-5203-7b92-a5d9-6f98c6414413@tnetconsulting.net> <CAN=4vMqDf3-rzCMqQ8TevU9VyLsqbCSC6-jEcODMgM7yfMW3YQ@mail.gmail.com> <34003-1694620880.833890@ywcd.55nf.YL_G> <4e08010c-b452-a807-ab0a-d40af8983203@tnetconsulting.net> <CAKc7PVAWcQ7HokZAF0LzoLciY3_cDSp0wzTkP=25ov+waKYmig@mail.gmail.com>
On 9/19/23 5:21 PM, Sebastian Gniazdowski wrote:
It fine to save the screen copy to a file, I can read it via $(<file).
Fair enough.
Does xterm can save the screen to a file, via the "media-copy" control
seq that you've mentioned?
XTerm can be configured to save content sent via media copy to a file.
N.B. media copy doesn't capture the screen to a file. Rather media copy
causes XTerm to take subsequent data and send it to the file.
You set media copy on, send data to -- ostensibly -- print to media, and
then set media copy off to return the terminal to normal operations.
Is there some example available of how to use it?
I've got things somewhere.
Hand typing this between terminals for $REASONS.
--8<--
#!/bin/bash
# Media Copy On
echo -n "^[[5i"
cat -
# Media Copy Off
echo -n "^[[4i"
-->8--
^[ is a stand in for the escape character.
This is the standard Control Sequence Introducer (CSI). Escape followed
by an open square bracket.
I use this with something like the following:
% uname -a | mediacopy
That causes uname's STDOUT to go into the mediacopy script's STDIN which
gets wrapped with the CSI 5 i or CSI 4 i.
I have the following configured in my ~/.Xdefaults:
--8<--
XTerm.vt100.printerCommand: /path/to/XTerm.vt100.printerCommand.sh
-->8--
My XTerm.vt100.printerCommand.sh is fairly simple.
--8<--
#!/bin/bash
cat - > `date +/path/to/destination.d/XTerm-printout-%Y%m%d-%H%M%S.txt`
-->8--
Remember to use xrdb et al. to load the updated ~/.Xdefaults file. Or
otherwise get the XTerm.vt100.printerCommand setting into X11.
--
Grant. . . .
unix || die
Messages sorted by:
Reverse Date,
Date,
Thread,
Author