summaryrefslogtreecommitdiffstats
path: root/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/lesspipe-highlight.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/.local/bin/lesspipe-highlight.sh b/.local/bin/lesspipe-highlight.sh
new file mode 100755
index 0000000..b55e513
--- /dev/null
+++ b/.local/bin/lesspipe-highlight.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# TODO: cache source-highlight extensions?
+
+# XXX: enable overriding
+LESSPIPE="$(which lesspipe.sh 2>/dev/null)"
+SHLPIPE="$(which src-hilite-lesspipe.sh 2>/dev/null)"
+
+SHLEXTS=
+
+[ -x "${LESSPIPE}" ] || LESSPIPE=cat
+[ -x "${SHLPIPE}" ] \
+ && SHLEXTS=$(source-highlight --lang-list | cut -d = -f1 | sed 's/^/\*./' | paste -d'|' -s) \
+ || SHLPIPE=cat
+
+eval "\
+ case \"$1\" in
+ ${SHLEXTS%|}) ${SHLPIPE} "$1";;
+ *) ${LESSPIPE} "$1";;
+ esac"