Aloxaf / fzf-tab

Replace zsh's default completion selection menu with fzf!
MIT License
2.98k stars 90 forks source link

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

Closed sweetbbak closed 4 months ago

sweetbbak commented 5 months ago

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:

To Reproduce

Steps to reproduce the behavior:

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

Environment:

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 {}'
Aloxaf commented 4 months ago

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'
sweetbbak commented 4 months ago

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