@ -13,14 +13,14 @@ if [[ $# -ne 1 ]]; then
fi
file = ${ 1 /# \~ \/ / $HOME / }
type = $( file --mime-type " $file " )
dim = ${ FZF_PREVIEW_COLUMNS } x${ FZF_PREVIEW_LINES }
if [ [ $dim = x ] ] ; then
dim = $( stty size | awk '{print $2 "x" $1}' )
fi
type = $( file --dereference --mime -- " $file " )
if [ [ ! $type = ~ image/ ] ] ; then
if [ [ $type = ~ = binary ] ] ; then
file " $1 "
exit
fi
# Sometimes bat is installed as batcat.
if command -v batcat > /dev/null; then
batname = "batcat"
@ -32,7 +32,19 @@ if [[ ! $type =~ image/ ]]; then
fi
${ batname } --style= " ${ BAT_STYLE :- numbers } " --color= always --pager= never -- " $file "
elif [ [ $KITTY_WINDOW_ID ] ] ; then
exit
fi
dim = ${ FZF_PREVIEW_COLUMNS } x${ FZF_PREVIEW_LINES }
if [ [ $dim = x ] ] ; then
dim = $( stty size < /dev/tty | awk '{print $2 "x" $1}' )
elif ! [ [ $KITTY_WINDOW_ID ] ] && ( ( FZF_PREVIEW_TOP + FZF_PREVIEW_LINES = = $( stty size < /dev/tty | awk '{print $1}' ) ) ) ; then
# Avoid scrolling issue when the Sixel image touches the bottom of the screen
# * https://github.com/junegunn/fzf/issues/2544
dim = ${ FZF_PREVIEW_COLUMNS } x$(( FZF_PREVIEW_LINES - 1 ))
fi
if [ [ $KITTY_WINDOW_ID ] ] ; then
# 1. 'memory' is the fastest option but if you want the image to be scrollable,
# you have to use 'stream'.
#
@ -42,6 +54,7 @@ elif [[ $KITTY_WINDOW_ID ]]; then
kitty icat --clear --transfer-mode= memory --stdin= no --place= " $dim @0x0 " " $file " | sed '$d' | sed $'$s/$/\e[m/'
elif command -v chafa > /dev/null; then
chafa -f sixel -s " $dim " " $file "
# Add a new line character so that fzf can display multiple images in the preview window
echo
else
file " $file "