-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlessfilter
More file actions
executable file
·27 lines (25 loc) · 872 Bytes
/
lessfilter
File metadata and controls
executable file
·27 lines (25 loc) · 872 Bytes
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
#! /usr/bin/env sh
# -*- mode: sh; coding: utf-8; -*-
# vim:set filetype=sh fileencoding=utf-8:
mime=$(file -bL --mime-type "$1")
category=${mime%%/*}
kind=${mime##*/}
if [ -d "$1" ]; then
if command -v eza 2>&1 >/dev/null; then
eza --color=always -h --no-permissions --octal-permissions --git --icons --tree -L 2 "$1"
else
# fallback to normal ls
ls "$1"
fi
# elif [ "$category" = image ]; then
# chafa -c 240 -s 80x25 "$1"
# exiftool "$1"
# elif [ "$kind" = vnd.openxmlformats-officedocument.spreadsheetml.sheet ] || \
# [ "$kind" = vnd.ms-excel ]; then
# in2csv "$1" | xsv table | bat -ltsv --color=always
elif [ "$category" = text ]; then
bat --color=always "$1"
else
lesspipe.sh "$1" | bat --color=always
fi
# lesspipe.sh doesn't use eza, bat and chafa, it use ls and exiftool. so we create a lessfilter.