chrisant996 / clink-fzf

Fzf integration for Clink
MIT License
75 stars 10 forks source link

Image preview in cmd #22

Closed ArkadiuszMichalski closed 1 month ago

ArkadiuszMichalski commented 1 month ago

Is there any easy way to add a preview images in cmd? The documentation mentions something about this, but there is only a .sh example.

chrisant996 commented 1 month ago

You would need a terminal that can support non-text terminal content. That's non-standard, and no terminals in Windows support non-text content. Some terminals in Linux have special extensions to allow showing some kind of non-text content.

The question is about terminals and operating systems, rather than about fzf (or Clink or clink-fzf).

ArkadiuszMichalski commented 1 month ago

I thought it was more popular these days. In the case of ConEmu there is issue for Sixel support: https://github.com/Maximus5/ConEmu/issues/807 https://www.arewesixelyet.com/

ArnaudKunzi commented 1 month ago

There is also support in wezterm, though it seems broken at the moment? It works trough the internal command wezterm imgcat although not necessarily through third party sixel programs.

chrisant996 commented 1 month ago

The fzf-preview.sh script is essentially just a wrapper script to check which text or graphics programs are available, check the file type, and then use one of the programs to generate a preview.

One of the graphics programs it looks for is chafa, which has a native Windows version.

Chafa is able to produce sixel output. I understand sixel support is coming soon to Windows Terminal, so that will be pretty interesting.

But in the meantime, chafa can produce other lower-fidelity block graphic image conversions. The default scale is 4.0 when using block graphics.

Original Chafa default scale (4.0) Chafa 2.0 scale Chafa 1.0 scale
RickAvatar image image image

So hey, that's interesting, even without sixel support.

I'll look into making some similar fzf-preview.cmd script. It will probably rely on bat for text files, and chafa for image files.

Since the spirit of fzf is to be highly customizable, and because previewing will depend on other programs which might not exist, I probably will not build in file preview "out of the box". Instead, just like with fzf itself, it will be require a tiny amount of customization, which can be shown in the README.md file (which already shows some customizations).

chrisant996 commented 1 month ago

The README.md file has been updated with instructions for how to configure previewing image files using the newly added fzf-preview.cmd script.

chrisant996 commented 1 month ago

(When sixel support becomes available in Windows Terminal, the script can be updated accordingly.)