dots-of-war/files/scripts/preview.sh

31 lines
478 B
Bash
Raw Normal View History

2020-09-25 18:56:00 +00:00
#!/bin/sh
2020-12-25 10:53:37 +00:00
case "$1" in
-*) exit 0;;
esac
2020-09-25 18:56:00 +00:00
case "$(file --mime-type "$1")" in
*text*)
2020-10-19 15:40:50 +00:00
bat --color always --plain --theme gruvbox "$1"
2020-09-25 18:56:00 +00:00
;;
*image* | *pdf)
if command -v timg; then
timg -g50x50 -E -F "$1"
elif command -v catimg; then
catimg -w 100 -r 2 "$1"
else
echo "Install timg or catimg to view images!"
fi
;;
*directory*)
exa --icons -1 --color=always "$1"
;;
*)
echo "unknown file format"
;;
esac