dotfiles/.config/lf/pv.sh

29 lines
829 B
Bash
Raw Normal View History

2022-08-13 05:26:11 +00:00
#!/bin/sh
img () {
2023-04-01 04:35:46 +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";;
*.rar) unrar l "$1";;
*.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