From 3277e8c89c2eaf18a1eb99898cdab79eb0be23d7 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 26 Oct 2023 21:36:57 +0900 Subject: [PATCH] Remove $FZF_PREVIEW_PIXEL_{WIDTH,HEIGHT} (#2544) They are not neccessary because we can use a program such as chafa that can resize images by the terminal columns and lines. --- CHANGELOG.md | 2 -- bin/fzf-preview.sh | 8 ++++++-- src/terminal.go | 4 ---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 706fda9..49008bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,6 @@ CHANGELOG 0.43.1 ------ - (Experimental) Sixel image support in preview window (not available on Windows) - - `$FZF_PREVIEW_PIXEL_WIDTH` and `$FZF_PREVIEW_PIXEL_HEIGHT` are set to - the pixel width and height of the preview window - [bin/fzf-preview.sh](bin/fzf-preview.sh) is added to demonstrate how to display an image using Kitty image protocol or Sixel. You can use it like so: diff --git a/bin/fzf-preview.sh b/bin/fzf-preview.sh index 82c0b25..fe405ef 100755 --- a/bin/fzf-preview.sh +++ b/bin/fzf-preview.sh @@ -2,6 +2,10 @@ # # The purpose of this script is to demonstrate how to preview a file or an # image in the preview window of fzf. +# +# Dependencies: +# - https://github.com/hpjansson/chafa +# - https://github.com/sharkdp/bat file=$1 type=$(file --mime-type "$file") @@ -23,8 +27,8 @@ elif [[ $KITTY_WINDOW_ID ]]; then # you have to use 'stream' kitty icat --clear --transfer-mode=memory --stdin=no --place="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0" "$file" | sed \$d echo -en "\e[m" -elif [[ -n $FZF_PREVIEW_PIXEL_WIDTH ]]; then - convert "$file" -resize "${FZF_PREVIEW_PIXEL_WIDTH}x${FZF_PREVIEW_PIXEL_HEIGHT}>" -dither FloydSteinberg sixel:- +elif command -v chafa > /dev/null; then + chafa -f sixel -s "${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file" else file "$file" fi diff --git a/src/terminal.go b/src/terminal.go index 504f4fd..0f184d3 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -2775,10 +2775,6 @@ func (t *Terminal) Loop() { env = append(env, "FZF_PREVIEW_"+lines) env = append(env, columns) env = append(env, "FZF_PREVIEW_"+columns) - if pwindowSize.PxWidth > 0 { - env = append(env, fmt.Sprintf("FZF_PREVIEW_PIXEL_WIDTH=%d", pwindowSize.PxWidth)) - env = append(env, fmt.Sprintf("FZF_PREVIEW_PIXEL_HEIGHT=%d", pwindowSize.PxHeight)) - } } cmd.Env = env