From 4f082b8c5c9f484a5d4b1f2fc11d472e49fcb6d3 Mon Sep 17 00:00:00 2001 From: Coko <91132775+Coko7@users.noreply.github.com> Date: Sun, 9 Feb 2025 06:04:35 +0100 Subject: [PATCH 1/3] Fix bin/fzf-preview.sh to use kitty icat for ghostty terminal --- bin/fzf-preview.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/fzf-preview.sh b/bin/fzf-preview.sh index e74e46e2cba..c9ba073450e 100755 --- a/bin/fzf-preview.sh +++ b/bin/fzf-preview.sh @@ -57,8 +57,8 @@ elif ! [[ $KITTY_WINDOW_ID ]] && (( FZF_PREVIEW_TOP + FZF_PREVIEW_LINES == $(stt dim=${FZF_PREVIEW_COLUMNS}x$((FZF_PREVIEW_LINES - 1)) fi -# 1. Use kitty icat on kitty terminal -if [[ $KITTY_WINDOW_ID ]]; then +# 1. Use kitty icat on kitty terminal and ghostty terminal +if [[ $KITTY_WINDOW_ID || $GHOSTTY_RESOURCES_DIR ]]; then # 1. 'memory' is the fastest option but if you want the image to be scrollable, # you have to use 'stream'. # From db43a84949e12e52f3c5137667661425488eec44 Mon Sep 17 00:00:00 2001 From: Coko <91132775+Coko7@users.noreply.github.com> Date: Sun, 9 Feb 2025 09:12:26 +0100 Subject: [PATCH 2/3] Fix bin/fzf-preview.sh to check if kitten is installed and use kitten icat rather than kitty icat (works with ghostty) --- bin/fzf-preview.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/fzf-preview.sh b/bin/fzf-preview.sh index c9ba073450e..6847babe148 100755 --- a/bin/fzf-preview.sh +++ b/bin/fzf-preview.sh @@ -57,15 +57,15 @@ elif ! [[ $KITTY_WINDOW_ID ]] && (( FZF_PREVIEW_TOP + FZF_PREVIEW_LINES == $(stt dim=${FZF_PREVIEW_COLUMNS}x$((FZF_PREVIEW_LINES - 1)) fi -# 1. Use kitty icat on kitty terminal and ghostty terminal -if [[ $KITTY_WINDOW_ID || $GHOSTTY_RESOURCES_DIR ]]; then +# 1. Use icat (from Kitty) if kitten is installed +if command -v kitten > /dev/null; then # 1. 'memory' is the fastest option but if you want the image to be scrollable, # you have to use 'stream'. # # 2. The last line of the output is the ANSI reset code without newline. # This confuses fzf and makes it render scroll offset indicator. # So we remove the last line and append the reset code to its previous line. - kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed '$d' | sed $'$s/$/\e[m/' + kitten icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed '$d' | sed $'$s/$/\e[m/' # 2. Use chafa with Sixel output elif command -v chafa > /dev/null; then From 231876a16240f385120464b73f14fd1ad73bd8e5 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 9 Feb 2025 19:51:10 +0900 Subject: [PATCH 3/3] Check env vars --- bin/fzf-preview.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/fzf-preview.sh b/bin/fzf-preview.sh index 6847babe148..ebf5b0d8008 100755 --- a/bin/fzf-preview.sh +++ b/bin/fzf-preview.sh @@ -58,7 +58,7 @@ elif ! [[ $KITTY_WINDOW_ID ]] && (( FZF_PREVIEW_TOP + FZF_PREVIEW_LINES == $(stt fi # 1. Use icat (from Kitty) if kitten is installed -if command -v kitten > /dev/null; then +if [[ $KITTY_WINDOW_ID ]] || [[ $GHOSTTY_RESOURCES_DIR ]] && command -v kitten > /dev/null; then # 1. 'memory' is the fastest option but if you want the image to be scrollable, # you have to use 'stream'. #