summaryrefslogtreecommitdiff
path: root/.local/bin/text-preview
blob: 4d0931d8cb6dd516e42aa210957761175742e51c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

# A simple text previewer.
# Useful in certain cases when you don't want to use your glorified previewer
# and just see the raw text content of a processable document like a markdown
# file.

[ -f "$1" ] && {
	if command -v highlight >/dev/null; then
		highlight --out-format=ansi -- "$1"
	elif command -v bat >/dev/null; then
		bat -- "$1"
	else
		cat -- "$1"
	fi
	exit
}

if command -v eza >/dev/null; then
	eza -alhF --group-directories-first --color=always --icons=always -- "$1"
else
	ls -lhAF --group-directories-first --color=always -- "$1"
fi