etc/lf/previewer

32 lines
558 B
Text
Raw Normal View History

2024-07-27 16:59:17 +03:00
#!/bin/sh
draw() {
2024-07-27 17:38:29 +03:00
if which kitten > /dev/null ; then
kitten icat --silent --stdin no --transfer-mode memory --place "${w}x${h}@${x}x${y}" "$1" </dev/null >/dev/tty
exit 1
fi
2024-07-27 16:59:17 +03:00
}
file="$1"
w="$2"
h="$3"
x="$4"
y="$5"
case "$(file -Lb --mime-type "$file")" in
image/*)
draw "$file"
;;
video/*)
# vidthumb is from here:
# https://raw.githubusercontent.com/duganchen/kitty-pistol-previewer/main/vidthumb
draw "$($ETC/lf/vidthumb "$file")"
;;
esac
2024-07-28 01:04:29 +03:00
if which bat> /dev/null ; then
pistol "$file" | bat
else
pistol "$file"
fi
2024-07-27 16:59:17 +03:00