-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
.lessfilter
executable file
·29 lines (28 loc) · 924 Bytes
/
.lessfilter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /usr/bin/env sh
# this is a example of .lessfilter, you can change it
mime=$(file -bL --mime-type "$1")
category=${mime%%/*}
kind=${mime##*/}
if [ -d "$1" ]; then
exa --git -hl --color=always --icons "$1"
elif [ "$category" = image ]; then
chafa --size 32x18 "$1"
echo ""
exiftool "$1"
elif [ "$kind" = vnd.openxmlformats-officedocument.spreadsheetml.sheet ] || \
[ "$kind" = vnd.ms-excel ]; then
in2csv "$1" | xsv table | bat -ltsv --color=always
elif [ "$kind" = csv ]; then
tv -c 4 -a "$1"
elif [ "$category" = text ]; then
bat --style=numbers --italic-text=always --color=always "$1"
elif [ "$kind" = pdf ]; then
pdftotext -f 0 "$1" -
else
if [ ! -s "$1" ]; then
bat --style=numbers --italic-text=always --color=always "$1"
else
bat --style=numbers --italic-text=always --color=always "$1"
fi
fi
# lesspipe.sh don't use exa, bat and chafa, it use ls and exiftool. so we create a lessfilter.