Syntax colorization when opening in less
This commit is contained in:
parent
626f977532
commit
c4ee895e27
2 changed files with 29 additions and 0 deletions
26
lessfilter.sh
Executable file
26
lessfilter.sh
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Use Pygments to get syntax colorization in less
|
||||
# export LESS=" -R"
|
||||
# export LESSOPEN='|~/code/dotfiles/lessfilter %s'
|
||||
|
||||
case "$1" in
|
||||
*.awk|*.groff|*.java|*.js|*.m4|*.php|*.pl|*.pm|*.pod|*.sh|\
|
||||
*.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"
|
||||
;;
|
||||
*)
|
||||
grep "#\!/bin/bash" "$1" > /dev/null
|
||||
if [[ "$?" -eq "0" ]]; then
|
||||
pygmentize -f 256 -l sh "$1"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue