fzf-tab: [BUG] Pictures previews not working with chafa and `-f kitty`
I can make sure:
- I am using the latest version of fzf-tab
- this is the minimal zshrc which can reproduce this bug
- fzf-tab is loaded after
compinit
- fzf-tab is loaded after plugins which will wrap <kbd>Tab</kbd>, like junegunn/fzf/completion.zsh
- fzf-tab is loaded before zsh-autosuggestions, zsh-syntax-highlighting and fast-syntax-highlighting.
Describe the bug
I followed the wiki for Previews - show file contents.
It works just fine with the following script (taken from the wiki too, slightly modified):
#! /usr/bin/env bash
has_cmd() { command -v "$1" >/dev/null 2>&1 ; }
MIME="$(file -bL --mime-type "$1")"
CATEGORY="${MIME%%/*}"
KIND="${MIME##*/}"
if [[ -d "$1" ]]; then
has_cmd exa && exa -a --color=always -l -g --git --group-directories-first --icons "$1"
has_cmd lsd && lsd -al --color=always --icon=always "$1"
elif [[ "$CATEGORY" == "image" ]]; then
has_cmd chafa && chafa "$1"
has_cmd exiftool && exiftool "$1"
elif [[ "$CATEGORY" == "text" ]]; then
has_cmd bat && bat --color=always --line-range :200 "$1"
elif [[ "$CATEGORY" == "video" ]]; then
has_cmd mediainfo && mediainfo "$1"
else
lesspipe.sh "$1" | bat --color=always --line-range :200
fi
Relevant part of my fzf-tab
config:
zstyle ':fzf-tab:complete:*:*' fzf-preview 'less ${(Q)realpath}'
zstyle ':fzf-tab:complete:*:*' fzf-flags --height=100% --preview-window=right:wrap
zstyle ':fzf-tab:complete:*:options' fzf-preview
zstyle ':fzf-tab:complete:*:argument-1' fzf-preview
export LESSOPEN='|/path/to/lessfilter.sh %s'
However, pictures previews aren’t working with chafa
when using kitty terminal (and default preview format).
From man chafa
:
-f, --format format
Set output format; one of [iterm, kitty, sixels, symbols]. The default is iterm, kitty or sixels if the connected terminal
supports one of these, falling back to symbols ("ANSI art") otherwise.
Since I’m using kitty, running chafa
without any argument defaults to -f kitty
, which doesn’t seem to work:
It works fine if run directly in terminal with:
❯ chafa 01.jpg
If using
chafa -f symbols "$1"
in the script, it works too, but the preview quality is very bad of course:
Environment:
- OS: Gentoo
❯ zsh --version
zsh 5.9 (x86_64-pc-linux-gnu)
❯ kitty --version
kitty 0.25.2 created by Kovid Goyal
❯ chafa --version
Chafa version 1.12.3
Am I missing something or is this a fzf limitation?
Thanks.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16
No worries, thanks for the suggestions! I don’t know either. Image previews with lf and Kitty protocol are working just fine too.
Yes, multiple formats, same behavior.
fzf now supports image