fzf sixel support on Windows
Checklist
- [x] I have read through the manual page (
man fzf) - [x] I have searched through the existing issues
- [x] For bug reports, I have checked if the bug is reproducible in the latest version of fzf
Output of fzf --version
0.62.0 (d226d841)
OS
- [ ] Linux
- [ ] macOS
- [x] Windows
- [ ] Etc.
Shell
- [ ] bash
- [ ] zsh
- [ ] fish
Problem / Steps to reproduce
I think this is the same bug as https://github.com/junegunn/fzf/issues/3682, but I can add more context and it is not really related to Wezterm / bash. Looks like it is just the way how fzf processes sixels on Windows. And there is a working go code that can do it =)
Repro in pwsh 7.5.1, WindowsTerminal 1.22.11141:
# no sixels
".\wallpapersden.com_curse-by-wlof_1920x1080.jpg" | fzf --preview "chafa {}"
# with sixels
".\wallpapersden.com_curse-by-wlof_1920x1080.jpg" | fzf --preview "chafa {} -f sixel --passthrough auto"
# Chafa sixels work
chafa .\wallpapersden.com_curse-by-wlof_1920x1080.jpg -f sixel --passthrough auto
What makes it interesting is that another TUI tool written in Go actually can render sixels on Windows. https://github.com/gokcehan/lf
» bat C:\Users\alexk\AppData\Local\lf\lfrc
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: C:\Users\alexk\AppData\Local\lf\lfrc
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ set previewer C:\\Users\\alexk\\Documents\\Powershell\\Data\\Winget\\preview.bat
2 │ set sixel
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
» bat C:\Users\alexk\Documents\Powershell\Data\Winget\preview.bat
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: C:\Users\alexk\Documents\Powershell\Data\Winget\preview.bat
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ @chafa.exe -f sixel --passthrough auto %*
───────┴─────────────────────────────────────────────────────────────────────────────────────────
» lf
Related to issue #3995.
As a workaround, you can specify the --height option with fzf and adjust the --view-size parameter for chafa. For instance, use --preview='chafa --view-size=18 -f sixel input.jpg'.
Thanks @georgejean for linking the issue.
So we can either fix #3799 in LightRenderer and drop the tcell renderer, or extend the tcell renderer to support image rendering. Since I'm not a Windows user and lack expertise in the platform, I probably won't be working on either, but pull requests are welcome.
Thanks! @georgejean, turns out using fzf --height (that forces using LightRenderer) is enough, no need to specify --view-size in chafa:
I've been previewing images with chafa in windows terminal since I learned about it supports sixels protocol. The final command I came up with is this:
$height = $env:FZF_PREVIEW_LINES
$width = $env:FZF_PREVIEW_COLUMNS
chafa -f sixels --colors=full --polite=on --animate=off -s "${width}x${height}" ./path/to/image