dotfiles/.config/lf/pv.sh

31 lines
843 B
Bash
Raw Normal View History

2022-08-13 05:26:11 +00:00
#!/bin/sh
img () {
2023-05-30 02:39:25 +00:00
chafa "$1" --size="$2"x"$3" --animate=false | sed 's/#/\n#/g'
#chafa --format=symbols "$1" --size="$2"x"$3"
}
2022-08-13 05:26:11 +00:00
W="$(($(tput cols)/2 - 10))"
#H="$(tput lines)"
fn="$1"
2023-03-10 04:54:58 +00:00
w="$(($2 - 5))"
2022-08-13 05:26:11 +00:00
h="$3"
x="$4"
y="$5"
case "$fn" in
*.tar*) tar tf "$1";;
*.zip) unzip -l "$1";;
2023-05-10 05:03:32 +00:00
*.rar) unrar-free -t "$1";;
2022-08-13 05:26:11 +00:00
*.7z) 7z l "$1";;
*.jpg | *.JPG | *.jpeg) img "$fn" "$w" "$h";;
*.webp) img "$fn" "$w" "$h";;
*.png | *.svg | *.gif) img "$fn" "$w" "$h";; #viu -t "$1" -w "$W" ;; #chafa "$fn" --size="$w"x"$h" ;;
2023-03-10 04:54:58 +00:00
*.mp4 | *.mkv | *.webm | *.avi | *.mpg | *.mpeg | *.ogv | *.flv | *.wmv | *.WMV) ffmpegthumbnailer -s 0 -i "$fn" -c jpeg -o - | img - "$w" "$h";;
2022-08-13 05:26:11 +00:00
*.pdf) pdftotext "$1" -;;
*) bat -f "$1";; #*) highlight -O ansi "$1" || cat "$1";;
esac
exit 0