1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-30 01:30:08 +00:00
ohmyzsh/plugins/colorize/colorize.plugin.zsh

30 lines
759 B
Bash
Raw Normal View History

2014-05-08 18:19:37 +00:00
# Plugin for highlighting file content
2013-04-12 14:19:42 +00:00
# Plugin highlights file content based on the filename extension.
# If no highlighting method supported for given extension then it tries
# guess it by looking for file content.
#easier alias to use plugin
alias ccat='colorize_via_pygmentize'
2013-04-12 14:19:42 +00:00
colorize_via_pygmentize() {
if [ ! -x "$(which pygmentize)" ]; then
echo "package \'Pygments\' is not installed!"
return -1
2013-04-12 14:19:42 +00:00
fi
if [ $# -eq 0 ]; then
pygmentize -g $@
fi
for FNAME in $@
do
filename=$(basename "$FNAME")
lexer=`pygmentize -N \"$filename\"`
if [ "Z$lexer" != "Ztext" ]; then
pygmentize -l $lexer "$FNAME"
else
pygmentize -g "$FNAME"
fi
done
2014-05-08 18:19:37 +00:00
}