mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-27 02:03:44 +01:00
Merge pull request #1714 from f0y/07738ea86330b7b77127fc6f18474b3da2c6ecec
Colorize plugin
This commit is contained in:
commit
b01a48d056
28
plugins/colorize/colorize.plugin.zsh
Normal file
28
plugins/colorize/colorize.plugin.zsh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Plugin for highligthing file content
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
alias colorize='colorize_via_pygmentize'
|
||||||
|
|
||||||
|
colorize_via_pygmentize() {
|
||||||
|
if [ ! -x $(which pygmentize) ]; then
|
||||||
|
echo package \'pygmentize\' is not installed!
|
||||||
|
exit -1
|
||||||
|
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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user