Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Is there a way of getting current xterm buffer?



Thanks. For completing screen-words, I would it seems need something different – so that the screen contents gets saved to the file in background, causing no visual or other effects for the user. Is this possible?

On Tue, 19 Sept 2023 at 22:06, Grant Taylor <gtaylor@xxxxxxxxxxxxxxxxxx> wrote:
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




--
Best regards,
Sebastian Gniazdowski



Messages sorted by: Reverse Date, Date, Thread, Author