Skip to content

Commit

Permalink
Merge pull request #1930 from danielb2/patch-1
Browse files Browse the repository at this point in the history
Have NNN_PREVIEWIMGPROG accept a generic command for preview-tui
  • Loading branch information
jarun authored Sep 15, 2024
2 parents 251843f + aa04d63 commit 07a972a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions plugins/preview-tui
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# - man
# - optional: bsdtar or atool for additional archive preview
# - optional: bat for code syntax highlighting
# - optional: ueberzug, kitty terminal, wezterm terminal, img2sixel, viu, catimg or chafa for images
# - optional: ueberzug, kitty terminal, wezterm terminal, img2sixel, viu, catimg, timg or chafa for images
# - optional: convert(ImageMagick) for playing gif preview (mandatory for kitty image previews)
# - optional: mpv for gif and video
# Also requires a terminal supporting the sixel (https://www.arewesixelyet.com/)
Expand Down Expand Up @@ -112,7 +112,7 @@ ENVVARS=(
"NNN_PREVIEWWIDTH=${NNN_PREVIEWWIDTH:-1920}" # width of generated preview images
"NNN_PREVIEWHEIGHT=${NNN_PREVIEWHEIGHT:-1080}" # height of generated preview images
"NNN_PREVIEWDIR=${NNN_PREVIEWDIR:-$TMPDIR/nnn/previews}" # location of generated preview images
"NNN_PREVIEWIMGPROG=${NNN_PREVIEWIMGPROG:-}" # program used to preview images
"NNN_PREVIEWIMGPROG=${NNN_PREVIEWIMGPROG:-}" # command used to preview images
"NNN_PREVIEWVIDEO=${NNN_PREVIEWVIDEO:-}" # mpv backend used to preview video
)
# Non-configurable environment variables
Expand Down Expand Up @@ -452,14 +452,8 @@ image_preview() {
wezterm imgcat "$3" &
elif exists ueberzug && [[ "$NNN_PREVIEWIMGPROG" == +(|ueberzug) ]]; then
ueberzug_layer "$1" "$2" "$3" && return
elif exists catimg && [[ "$NNN_PREVIEWIMGPROG" == +(|catimg) ]]; then
catimg "$3" &
elif exists viu && [[ "$NNN_PREVIEWIMGPROG" == +(|viu) ]]; then
viu -t "$3" &
elif exists chafa && [[ "$NNN_PREVIEWIMGPROG" == +(|chafa) ]]; then
chafa "$3" &
elif exists img2sixel && [[ "$NNN_PREVIEWIMGPROG" == +(|img2sixel) ]]; then
img2sixel -g "$3" &
elif exists "${NNN_PREVIEWIMGPROG%% *}"; then # can include command flags; only check first word
"$NNN_PREVIEWIMGPROG" "$3" &
else
fifo_pager print_bin_info "$3" && return
fi
Expand Down

0 comments on commit 07a972a

Please sign in to comment.