Created
September 22, 2011 21:31
-
-
Save nandhp/1236119 to your computer and use it in GitHub Desktop.
lesspipe + source-highlight integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# .lessfilter - Custom rules for lesspipe | |
# | |
# GNU source-highlight | |
SRC=/usr/bin/source-highlight | |
SRCOPTS="-f esc --style-file=esc.style -i" | |
# Directory listings | |
if [ -d "$1" ]; then | |
ls -lh --color "$1" | |
exit 0 | |
fi | |
# Custom rules | |
#case "$1" in | |
# *.extension) | |
# extension-handler "$1" | |
# exit 0 | |
# ;; | |
#esac | |
# Otherwise, try source highlighting | |
# Based on /usr/share/source-highlight/src-hilite-lesspipe.sh | |
case "$1" in | |
*ChangeLog|*changelog) | |
[ -x "$SRC" ] && \ | |
"$SRC" $SRCOPTS "$1" --lang-def=changelog.lang && exit 0 | |
;; | |
*Makefile|*makefile) | |
[ -x "$SRC" ] && \ | |
"$SRC" $SRCOPTS "$1" --lang-def=makefile.lang && exit 0 | |
;; | |
*) | |
[ -x "$SRC" ] && \ | |
"$SRC" $SRCOPTS "$1" --infer-lang && exit 0 | |
;; | |
esac | |
# Process further with lesspipe | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The CentOS 7 system lesspipe (
/usr/bin/lesspipe.sh
):Otherwise, works great, thanks!