commit 07a972a4856116db728f63a32df7f2a8253c718c
parent 251843fe65189b7ac56f0bea208e7a03d92b2c81
Author: Arun <engineerarun@gmail.com>
Date: Sun, 15 Sep 2024 22:35:37 +0530
Merge pull request #1930 from danielb2/patch-1
Have NNN_PREVIEWIMGPROG accept a generic command for preview-tui
Diffstat:
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/plugins/preview-tui b/plugins/preview-tui
@@ -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/)
@@ -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
@@ -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