lf/previewer.sh

23 lines
541 B
Bash
Executable File

#!/bin/sh
file="$1"
case "$file" in
*.tar*) tar tf -- "$file" ;;
*.zip) unzip -l -- "$file" ;;
*.rar) unrar l -- "$file" ;;
*.7z) 7z l -- "$file" ;;
*.pdf) pdftotext -- "$file" - ;;
*.jpg|*.jpeg|*.png|*.gif|*.bmp|*.webp)
if command -v chafa >/dev/null 2>&1; then
chafa -f symbols --animate=off -- "$file"
elif command -v img2txt >/dev/null 2>&1; then
img2txt -- "$file"
else
file -- "$file"
fi
;;
*.md) mdcat -- "$file" ;;
*) bat --terminal-width 120 --wrap auto --color always --theme base16 -- "$file" ;;
esac