Closed mattbaker closed 1 year ago
I was just trying to do the same and got the same result. If this is not possible, is there an alternative to preview images on MacOS?
I glanced at the preview function (https://github.com/junegunn/fzf/blob/master/src/terminal.go#L1018), I can see it's doing some parsing for the ANSI codes used to represent colors. I wonder if the problem is that it ends up stripping part of the escape sequence iTerm2 expects to see in the output to trigger the image rendering.
So I did some more digging around, extractColor
in https://github.com/junegunn/fzf/blob/master/src/ansi.go is the function used to detect the color sequences, which are different, but start in a similar way. It does it like this:
So my takeaway (as a random developer who stumbled into this, not as any one who has experience with this project) is we can't reuse ansi functionality for this escape sequence because neither the state variable in ansi.go, nor CFill was designed to handle this case, and won't be able to handle it without significant changes to the logic (so to keep things clean, it's better to leave that alone).
However, what I would recommend (to the brave soul who decides to implement this, since I don't have time to do so myself, unfortunately), is the following:
Would other image protocols fare any better? Kitty's implementation seems fairly diffrent, though maybe not in the relevant ways. sixel aims at more universal support, see e.g.: https://github.com/hackerb9/lsix
Somewhat related, but would it be difficult to allow preview to support image rendering via mdcat?
mdcat
renders markdown documents with images in kitty fine, but when attempting to use mdcat to preview files (--preview 'mdcat {}'
), the image get replaced with some long string starting with "Ga=T,t=d,..", e.g.:
Ga=T,t=d,f=24,s=659,v=374,m=1;/////Pz8////9PT0/Pz88/Pz+...
Could you add sixel support ?
Somewhat related, but would it be difficult to allow preview to support image rendering via mdcat?
mdcat
renders markdown documents with images in kitty fine, but when attempting to use mdcat to preview files (--preview 'mdcat {}'
), the image get replaced with some long string starting with "Ga=T,t=d,..", e.g.:Ga=T,t=d,f=24,s=659,v=374,m=1;/////Pz8////9PT0/Pz88/Pz+...
I'm also wondering if it is possible.
Is it possible to get iTerm2's
imgcat
shell integration working in an fzf preview? https://www.iterm2.com/documentation-images.htmlI'm guessing this is at the core of the issue:
Right now I just see plain text (1337 followed by the relevant key-value pairs) which wasn't a shock, but I am curious if there's a way to get it working :) As you can imagine, piping images through imgcat in a fzf
preview
command would look really cool!