lf: kitty-0.27.0 preview not working due to change in icat's transfer mode
Hi, I was having a problem with my previewer script, which is rather complex.
So I just commented everything and tried the basic example script from the documentation:
#!/bin/sh
file=$1
w=$2
h=$3
x=$4
y=$5
if [[ "$( file -Lb --mime-type "$file")" =~ ^image ]]; then
kitty +icat --silent --transfer-mode file --place "${w}x${h}@${x}x${y}" "$file" && echo "$file" >> lemmesee
exit 1
fi
As you can see, I added the && echo 'success' >> lemmesee
at the bottom of the command.
The file never gets created in the first place when I hover on some image. The weird part is that, if I manually run that command it works flawlessly.
This is the relevant configuration file:
set shell sh
set shellopts '-eu'
set ifs "\n"
set icons
set mouse
set scrolloff 10
set drawbox
set ignorecase true
set previewer ~/.config/lf/preview.sh
set cleaner ~/.config/lf/clean.sh
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 10
- Comments: 20 (4 by maintainers)
Commits related to this issue
- workaround for kitty preview issue - https://github.com/gokcehan/lf/issues/1099 — committed to hurngchunlee/dotfiles by hurngchunlee a year ago
- fix(lf): workaround kitty image previewer issue see: https://github.com/gokcehan/lf/issues/1099 — committed to latipun7/dotfiles by latipun7 a year ago
I had the same issue when I tried running it without
--transfer-mode file
, however with it, all works as expected. This is what my scripts currently look like:lf_kitty_clean
:lf_kitty_preview
:I am having the exact same issue. I am able to view images in my kitty terminal and in the shell created by clicking
w
, ButLf
isn’t able to display the generated image even though I can view it directly in my terminal with kitty. I verified that the thumbnail was generated like expected butLf
is unable to display the image. I have a gut feeling that it might have something to do with the new improvements in kitty.@ignamartinoli
NOTE: due to a recent change in kitty 0.27.0, the '+kitten' subcommand is needed to run all kitty kittens .ie $ kitty +kitten icat
but this still doesn’t work.@rockyzhang24 I use your previewer config but ended in crash once I push
return
w
button trying to enter bash with the image’s preview by the side.zsh: suspended (tty output) lf
once I tried to input something, kitty closed. I didn’t find the reason.@Kazuma-chan Anyway it works on my side, so it means no issues for kitty and lf. I recommend you to install lf by the command I mentioned above and see if your issue is resolved.
The new kitty preview and clean command work perfectly but this sometimes crushs the
lf
instance orthe shell
when entering/opening a sub shell with thew
default map.To reproduce
open
lf
in a new terminal window highlight an image for previewer to kick in press thew
keyThis produces an error
zsh: suspended (tty output) lf
when you try to reopen

lf
imediately afterwards in the shell you are drop in you get the errorzsh: error on TTY read: Error from entering/leaving
The link to my lf configuration files
The author of kitty pointed out a trick to fix this. Please change the command to
kitten icat --transfer-mode file --stdin no --place "${w}x${h}@${x}x${y}" "$file" < /dev/null > /dev/tty
.For details, see https://github.com/kovidgoyal/kitty/issues/6010 please.