helm/bin/lesspipe

19 lines
558 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
# Read a file with possible syntax coloring applied
2014-11-18 20:51:52 -08:00
case "$1" in
*.awk|*.groff|*.java|*.js|*.m4|*.php|*.pl|*.pm|*.pod|*.sh|\
2014-11-18 20:51:52 -08:00
*.ad[asb]|*.asm|*.inc|*.[ch]|*.[ch]pp|*.[ch]xx|*.cc|*.hh|\
*.lsp|*.l|*.pas|*.p|*.xml|*.xps|*.xsl|*.axp|*.ppd|*.pov|\
*.diff|*.patch|*.py|*.rb|*.sql|*.ebuild|*.eclass)
pygmentize -f 256 "$1" ;;
.bashrc|.bash_aliases|.bash_environment)
pygmentize -f 256 -l sh "$1" ;;
*)
if ! grep "#\!/.+[/ ](ba|z)?sh" "$1" >/dev/null; then
exit 1
fi
pygmentize -f 256 -l sh "$1"
2014-11-18 20:51:52 -08:00
esac