Re: imgcat script not working in screen

Neal Fultz <[email protected]> Fri, 1 Sep 2023 11:53:45 -0700
Newsgroups gmane.comp.gnu.screen.user
Message-ID <CAL9B2vfxKJc26apHrPjgJ3eeUtSS4u0TYKv-iXPiDKt_0hjW0Q@mail.gmail.com>
--000000000000496a1d060450b06e
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I use similar scripts from google's hterm project; to the extent that hterm
is "iterm2 compatible" maybe they will work for you. I adapted them to
support screen for the terminal graphics device in R. IIRC the scripts have
a tweak to work with screen's buffer size for escaped data.

https://chromium.googlesource.com/apps/libapps/+/master/hterm/etc/

On Thu, Aug 31, 2023 at 11:25=E2=80=AFPM Pier Giuseppe Fogli <
[email protected]> wrote:

> Hi,
> I'd like to be able to use the imgcat shell script from inside GNU screen
> in order to display images from remote hosts.
> imgcat (https://iterm2.com/utilities/imgcat) is part of a collection of
> shell scripts that make use of iTerm2 image display capabilities,
> here the related documentation:
> https://iterm2.com/documentation-images.html
>
> It works outside GNU screen. From inside it generate a stream of
> base 64 encoded text on the terminal.
> I guess the problem here is to escape this stream from GNU screen
> interpretation in some way, and let it be interpreted by the terminal
> emulator.
> According to the imgcat script it should be handled by this function:
>
> # tmux requires unrecognized OSC sequences to be wrapped with DCS tmux;
> # <sequence> ST, and for all ESCs in <sequence> to be replaced with ESC
> ESC. It
> # only accepts ESC backslash for ST. We use TERM instead of TMUX because
> TERM
> # gets passed through ssh.
> function print_osc() {
>     if [[ $TERM =3D=3D screen* || $TERM =3D=3D tmux* ]]; then
>         printf "\033Ptmux;\033\033]"
>     else
>         printf "\033]"
>     fi
> }
>
> but it doesn't and I can't figure out how to fix it.
> Any idea?
>
> Thanks in advance,
> PGF
>

--000000000000496a1d060450b06e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I use similar scripts from google&#39;s hterm project; to =
the extent that hterm is &quot;iterm2 compatible&quot; maybe they will work=
 for you. I adapted them to support screen for the terminal graphics device=
 in R. IIRC the scripts have a tweak to work with screen&#39;s buffer size =
for escaped=C2=A0data.<div><br></div><div><a href=3D"https://chromium.googl=
esource.com/apps/libapps/+/master/hterm/etc/">https://chromium.googlesource=
.com/apps/libapps/+/master/hterm/etc/</a><br></div></div><br><div class=3D"=
gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Thu, Aug 31, 2023 at =
11:25=E2=80=AFPM Pier Giuseppe Fogli &lt;<a href=3D"mailto:piergiuseppe.fog=
[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote =
class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px sol=
id rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Hi,<br>I&#39;d like =
to be able to use the imgcat shell script from inside GNU screen<br>in orde=
r to display images from remote hosts.<br>imgcat (<a href=3D"https://iterm2=
.com/utilities/imgcat" target=3D"_blank">https://iterm2.com/utilities/imgca=
t</a>) is part of a collection of<br>shell scripts that make use of iTerm2 =
image display capabilities,<br>here the related documentation:<br><a href=
=3D"https://iterm2.com/documentation-images.html" target=3D"_blank">https:/=
/iterm2.com/documentation-images.html</a><br><br>It works outside GNU scree=
n. From inside it generate a stream of<br>base 64 encoded text on the termi=
nal.<br>I guess the problem here is to escape this stream from GNU screen<b=
r>interpretation in some way, and let it be interpreted by the terminal emu=
lator. <br>According to the imgcat script it should be handled by this func=
tion:<br><br># tmux requires unrecognized OSC sequences to be wrapped with =
DCS tmux;<br># &lt;sequence&gt; ST, and for all ESCs in &lt;sequence&gt; to=
 be replaced with ESC ESC. It<br># only accepts ESC backslash for ST. We us=
e TERM instead of TMUX because TERM<br># gets passed through ssh.<br>functi=
on print_osc() {<br>=C2=A0 =C2=A0 if [[ $TERM =3D=3D screen* || $TERM =3D=
=3D tmux* ]]; then<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 printf &quot;\033Ptmux;\0=
33\033]&quot;<br>=C2=A0 =C2=A0 else<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 printf &=
quot;\033]&quot;<br>=C2=A0 =C2=A0 fi<br>}<br><br>but it doesn&#39;t and I c=
an&#39;t figure out how to fix it.<div>Any idea?<br><br>Thanks in advance,<=
br>PGF</div></div>
</blockquote></div>

--000000000000496a1d060450b06e--