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

23 lines
460 B
Bash
Raw Normal View History

2020-10-30 22:02:38 +02:00
#! /bin/sh
2020-09-25 20:56:00 +02:00
2020-10-30 22:02:38 +02:00
type="$(file --mime-type "$@")"
2020-09-25 20:56:00 +02:00
2020-10-30 22:02:38 +02:00
case "$type" in
2020-09-25 20:56:00 +02:00
*text*)
2020-10-30 22:02:38 +02:00
bat --color always --plain --theme gruvbox "$@"
2020-09-25 20:56:00 +02:00
;;
*image* | *pdf)
2020-10-30 22:02:38 +02:00
[ "$(command -v timg)" ] && \
timg -g50x50 -E -F "$@" || \
[ "$(command -v catimg)" ] && \
catimg -w 100 -r 2 "$@" || \
2020-09-25 20:56:00 +02:00
echo "Install timg or catimg to view images!"
;;
*directory*)
2020-10-30 22:02:38 +02:00
exa --icons -1 --color=always "$@"
2020-09-25 20:56:00 +02:00
;;
*)
echo "unknown file format"
;;
esac