kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.15k stars 972 forks source link

Possible pipe conflict between icat kitten and bash #5741

Closed gknittl closed 1 year ago

gknittl commented 1 year ago

Describe the bug pipe conflict between icat kitten and bash?

*To Reproduce (for kitty --config NONE)** This displays the kitty logo twice on the screen: kitty +kitten icat https://sw.kovidgoyal.net/kitty/_static/kitty.svg; kitty +kitten icat https://sw.kovidgoyal.net/kitty/_static/kitty.svg This displays the kitty logo once on the screen, followed by an error: { echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; } | while read line; do kitty --debug-input +kitten icat $line; done Failed to open image: /tmp/tty-graphics-protocol-08x889_h with error: identify-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/560.

Screenshots available if necessary

Environment details (for kitty --config NONE) kitty 0.26.5 created by Kovid Goyal Linux greg-HP-ProDesk-600-G2-SFF 5.15.0-56-generic #62~20.04.1-Ubuntu SMP Tue Nov 22 21:24:20 UTC 2022 x86_64 Ubuntu 20.04.5 LTS greg-HP-ProDesk-600-G2-SFF /dev/tty

DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS" Running under: X11 Frozen: True Paths: kitty: /home/greg/.local/kitty.app/bin/kitty base dir: /home/greg/.local/kitty.app/lib/kitty extensions dir: /home/greg/.local/kitty.app/lib/kitty-extensions system shell: /bin/bash

Config options different from defaults:

Important environment variables seen by the kitty process: PATH [available if necessary] LANG en_CA.UTF-8 SHELL /bin/bash DISPLAY :0 USER greg XDG_CONFIG_DIRS /etc/xdg/xdg-ubuntu:/etc/xdg XDG_MENU_PREFIX gnome- XDG_SESSION_DESKTOP ubuntu XDG_SESSION_TYPE x11 XDG_CURRENT_DESKTOP ubuntu:GNOME XDG_SESSION_CLASS user XDG_RUNTIME_DIR /run/user/1000 XDG_DATA_DIRS /usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop

Additional Environment convert -version Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org Copyright: © 1999-2019 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC Modules OpenMP Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib

gknittl commented 1 year ago

sorry { echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; } | while read line; do kitty --debug-input +kitten icat $line; done should read { echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; } | while read line; do kitty +kitten icat $line; done I couldn't get --debug-input to work with +kitten

kovidgoyal commented 1 year ago

One of the echos will be passed to the STDIN of the program inside your while loop. You need to use

{ echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; } | while read line; do kitty +kitten icat $line < /dev/null; done

Or better yet use a real programming language rather than a bash script then you wont have these gotchas. Since you are depending on kitty already use

kitty +launch myscript.py

gknittl commented 1 year ago

thanks! works. I will have to ponder why it works... much appreciated.

gknittl commented 1 year ago

Thanks again for your work on kitty. As more applications support the kitty image protocol, I'm tending to run them under kitty instead of in OS windows.

The solution from Dec 6th above is still working but now writes an error message before each image:

{ echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; } | while read line; do kitty +kitten icat $line < /dev/null; done

Failed to process : ImageMagick failed: Running the command: identify -format {"fmt":"%m","canvas":"%g","transparency":"%A","gap":"%T","index":"%p","size":"%wx%h","dpi":"%xx%y","dispose":"%D","orientation":"%[EXIF:Orientation]"}, -- /dev/shm/kitty-tty-graphics-protocol-3699754387 Failed with error: identify-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/572.

[kitty icon displays here]

Failed to process : ImageMagick failed: Running the command: identify -format {"fmt":"%m","canvas":"%g","transparency":"%A","gap":"%T","index":"%p","size":"%wx%h","dpi":"%xx%y","dispose":"%D","orientation":"%[EXIF:Orientation]"}, -- /dev/shm/kitty-tty-graphics-protocol-1595460879 Failed with error: identify-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/572.

[kitty icon displays here]

I'm still on Ubuntu 20.04, the imagemagick version is unchanged from December 2022. I'm able to reproduce the issue on the kitty nightly build as well as kitty 0.29.1

kovidgoyal commented 1 year ago

You want

{ echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; echo https://sw.kovidgoyal.net/kitty/_static/kitty.svg; } | while read line; do kitten icat --stdin=no "$line" < /dev/null; done