Kitty image support improvements
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Use `--unicode-placeholder` for consistent result in and out of tmux * Use updated version of junegunn/go-runewidth that handles diacritics used in Kitty Unicode placeholder Close #3567
authored by Junegunn Choi · committed by Junegunn Choi · parent cdfaf76 · Browse files · 5 files·+6 added−6 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+6 added−6 removed
- other:+6 added−6 removed
Provenance
- Commit
e7718b9- Tree
260dbea- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
cdfaf76
5 files changed+6 added−6 removed
modified:bin/fzf-preview.sh+1 added-1 removed
51 unmodified lines5253545556565758596014 unmodified lines51 unmodified lines # # 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 --stdin=no --place="$dim@0x0" "$file" | sed '$d' | sed $'$s/$/\e[m/' kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed '$d' | sed $'$s/$/\e[m/'
# 2. Use chafa with Sixel outputelif command -v chafa > /dev/null; then chafa -f sixel -s "$dim" "$file"14 unmodified linesmodified:CHANGELOG.md+1 added-1 removed
122 unmodified lines123 if file --mime-type {} | grep -qF image/; then124 # --transfer-mode=memory is the fastest option but if you want fzf to be able125 # to redraw the image on terminal resize or on 'change-preview-window',126 # you need to use --transfer-mode=stream.127- kitty icat --clear --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {} | sed \$d127+ kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {} | sed \$d128 else129 bat --color=always {}130 fi131 '1720 unmodified linesmodified:go.mod+1 added-1 removed
1 module github.com/junegunn/fzf2 3 require (4 github.com/gdamore/tcell/v2 v2.5.45- github.com/junegunn/go-runewidth v0.0.0-20240114080738-1b95d8d53ad85+ github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab486 github.com/mattn/go-isatty v0.0.177 github.com/mattn/go-shellwords v1.0.128 github.com/rivo/uniseg v0.4.49 github.com/saracen/walker v0.1.313 unmodified linesmodified:go.sum+2 added-2 removed
1 github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=2 github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=3 github.com/gdamore/tcell/v2 v2.5.4 h1:TGU4tSjD3sCL788vFNeJnTdzpNKIw1H5dgLnJRQVv/k=4 github.com/gdamore/tcell/v2 v2.5.4/go.mod h1:dZgRy5v4iMobMEcWNYBtREnDZAT9DYmfqIkrgEMxLyw=5-github.com/junegunn/go-runewidth v0.0.0-20240114080738-1b95d8d53ad8 h1:qcSgFcU7GG0oYYbUzJJvv2AcJRPzjVZLwrL4ZahMpOw=6-github.com/junegunn/go-runewidth v0.0.0-20240114080738-1b95d8d53ad8/go.mod h1:Mq6NazeZhIIQPMFoInCi35AktcN/MuW2elHsDK5N52w=5+github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab48 h1:546WmTZE4BUDJXhKlsaqhgdAPt+yWp82cNkzJxsvVDQ=6+github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab48/go.mod h1:Mq6NazeZhIIQPMFoInCi35AktcN/MuW2elHsDK5N52w=7 github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=8 github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=9 github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=10 github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=42 unmodified linesmodified:README.md+1 added-1 removed
739 unmodified lines740 741 ```sh742 fzf --preview='743 if file --mime-type {} | grep -qF image/; then744- kitty icat --clear --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {} | sed \$d744+ kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {} | sed \$d745 else746 bat --color=always {}747 fi748 '65 unmodified lines