Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ###
- ### Add the following to your .bashrc:
- # export LESS='-FRX'
- # export LESSOPEN='|~/.lessfilter %s'
- ## And if you want to alias cat aswell;
- # alias cat='~/.lessfilter'
- pygm_opts="-f terminal16m -O style=monokai"
- case `basename $1` in
- *.awk|*.groff|*.java|*.js|*.m4|*.pl|*.pm|*.pod|*.sh|\
- *.ad[asb]|*.asm|*.inc|*.[ch]|*.[ch]pp|*.[ch]xx|*.cc|*.hh|\
- *.lsp|*.l|*.pas|*.p|*.xps|*.xsl|*.axp|*.ppd|*.pov|\
- Makefile|\
- *.diff|*.patch|*.py|*.rb|*.sql|*.ebuild|*.eclass)
- pygmentize $pygm_opts "$1";;
- *.php|*.inc|*.module|*.install)
- pygmentize $pygm_opts -l php -O style=native "$1";;
- *.md)
- pygmentize $pygm_opts "$1";;
- *.xml)
- xmllint --format --nonet --nowarning --nocatalogs --nsclean --recover "$1" | pygmentize $pygm_opts -O style=native -O nowrap=true -l xml 2>/dev/null;;
- *.info)
- pygmentize $pygm_opts -l ini 2>/dev/null "$1";;
- .gitconfig|.gitignore)
- pygmentize $pygm_opts -l kconfig 2>/dev/null "$1";;
- *.json)
- cat "$1" | jq -M . | pygmentize $pygm_opts -O style=paraiso-dark -l json 2>/dev/null;;
- .bashrc|.bash_aliases|.bash_environment)
- pygmentize $pygm_opts -O style=rrt -l sh "$1"
- ;;
- *)
- egrep "#\!\/bin\/(bash|sh)" "$1" > /dev/null
- if [ "$?" -eq "0" ]; then
- pygmentize $pygm_opts -O style=native -l sh "$1"
- else
- exit 1
- fi
- esac
- exit 0
Add Comment
Please, Sign In to add comment