Aloxaf / fzf-tab

Replace zsh's default completion selection menu with fzf!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kitty +kitten icat works with FZF but does not work with fzf-preview [BUG]

sweetbbak opened this issue · comments

Describe the bug

running icat for the Kitty Image Protocol does not work as a method to view images using fzf-tab. It does work with FZF though.
Here as an example of this working with FZF:

 fd . "${1}" -tf -e gif -e jpg -e jpeg -e png -e svg -e webp | fzf --preview='
if file --mime-type {} | grep -qF 'image/'; then
  # --transfer-mode=memory is the fastest option but if you want fzf to be able
  # to redraw the image on terminal resize or on 'change-preview-window',
  # you need to use --transfer-mode=stream.
  kitty icat --clear --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {}
else
  bat --color=always {}
fi
'

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 Tab, like junegunn/fzf/completion.zsh
  • fzf-tab is loaded before zsh-autosuggestions, zsh-syntax-highlighting and fast-syntax-highlighting.

To Reproduce

Steps to reproduce the behavior:

  1. Type "icat ~/Pictures/"
  2. Press Tab
  3. No images appear.

Environment:

  • OS: Arch Linux
  • zsh version: 6.6.10-arch1-1

Minimal zshrc

If applicable, add a minimal zshrc to help us analyze.

# Attempt 1
# zstyle ':fzf-tab:complete:kitten:icat:*' fzf-preview 'kitten icat --clear --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 $realpath'

# Attempt 2
zstyle ':fzf-tab:complete:kitten:icat:*' fzf-preview 'kitten icat --clear --transfer-mode=memory --stdin=no --place=10x10@0x0 ${(Q)realpath}'

# Attempt 3
zstyle ':fzf-tab:complete:icat:argument-1' fzf-preview \
  'kitten icat --clear --transfer-mode=memory --stdin=no --place=30x30@0x0 {}'

The kitten's completion script doesn't define a context for icat subcommand, so unfortunately you cannot define preview for it separately.

A workaround is:

icat() {
    kitten icat $@
}
zstyle ':fzf-tab:complete:icat:*' fzf-preview 'kitten icat --clear --transfer-mode=memory --stdin=no --place=30x30@0x0 $realpath'

Thanks for the help. I love this project btw I couldn't go without it at this point.