summaryrefslogtreecommitdiff
path: root/.local/bin/text-preview
diff options
context:
space:
mode:
authorVikas Kushwaha <dev@vikas.rocks>2025-02-07 18:03:41 +0530
committerVikas Kushwaha <dev@vikas.rocks>2025-02-07 18:03:41 +0530
commit5940d14ddbdb6f68869f48351083875b11b6abf7 (patch)
tree9a5cc0f1268933ca0d5a1a7d2882e93766c25250 /.local/bin/text-preview
parent18507fd21b7a7709133d8f3049c683e1abffcda2 (diff)
preview updates
Diffstat (limited to '.local/bin/text-preview')
-rwxr-xr-x.local/bin/text-preview23
1 files changed, 23 insertions, 0 deletions
diff --git a/.local/bin/text-preview b/.local/bin/text-preview
new file mode 100755
index 0000000..4d0931d
--- /dev/null
+++ b/.local/bin/text-preview
@@ -0,0 +1,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