Merge pull request #1930 from danielb2/patch-1

Have NNN_PREVIEWIMGPROG accept a generic command for preview-tui
This commit is contained in:
Arun 2024-09-15 22:35:37 +05:30 committed by GitHub
commit 07a972a485
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,7 +21,7 @@
# - man # - man
# - optional: bsdtar or atool for additional archive preview # - optional: bsdtar or atool for additional archive preview
# - optional: bat for code syntax highlighting # - 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: convert(ImageMagick) for playing gif preview (mandatory for kitty image previews)
# - optional: mpv for gif and video # - optional: mpv for gif and video
# Also requires a terminal supporting the sixel (https://www.arewesixelyet.com/) # 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_PREVIEWWIDTH=${NNN_PREVIEWWIDTH:-1920}" # width of generated preview images
"NNN_PREVIEWHEIGHT=${NNN_PREVIEWHEIGHT:-1080}" # height 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_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 "NNN_PREVIEWVIDEO=${NNN_PREVIEWVIDEO:-}" # mpv backend used to preview video
) )
# Non-configurable environment variables # Non-configurable environment variables
@ -452,14 +452,8 @@ image_preview() {
wezterm imgcat "$3" & wezterm imgcat "$3" &
elif exists ueberzug && [[ "$NNN_PREVIEWIMGPROG" == +(|ueberzug) ]]; then elif exists ueberzug && [[ "$NNN_PREVIEWIMGPROG" == +(|ueberzug) ]]; then
ueberzug_layer "$1" "$2" "$3" && return ueberzug_layer "$1" "$2" "$3" && return
elif exists catimg && [[ "$NNN_PREVIEWIMGPROG" == +(|catimg) ]]; then elif exists "${NNN_PREVIEWIMGPROG%% *}"; then # can include command flags; only check first word
catimg "$3" & "$NNN_PREVIEWIMGPROG" "$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" &
else else
fifo_pager print_bin_info "$3" && return fifo_pager print_bin_info "$3" && return
fi fi