07738ea86330b7b77127fc6f18474b3da2c6ecec

Author
Oleg Kandaurov <okandaurov@at-consulting.ru>
Committer
Oleg Kandaurov <okandaurov@at-consulting.ru>
Date

Message

Add colorize plugin

Diff

 1diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..0696607d9fdc9d3e31df0552db55596d5dd6d22d
 4--- /dev/null
 5+++ b/plugins/colorize/colorize.plugin.zsh
 6@@ -0,0 +1,28 @@
 7+# Plugin for highligthing file content
 8+# Plugin highlights file content based on the filename extension.
 9+# If no highlighting method supported for given extension then it tries 
10+# guess it by looking for file content.
11+
12+alias colorize='colorize_via_pygmentize'
13+
14+colorize_via_pygmentize() {
15+    if [ ! -x $(which pygmentize) ]; then
16+        echo package \'pygmentize\' is not installed!
17+        exit -1
18+    fi
19+
20+    if [ $# -eq 0 ]; then
21+        pygmentize -g $@
22+    fi
23+
24+    for FNAME in $@
25+    do
26+        filename=$(basename "$FNAME")
27+        lexer=`pygmentize -N \"$filename\"`
28+        if [ "Z$lexer" != "Ztext" ]; then
29+            pygmentize -l $lexer "$FNAME"
30+        else
31+            pygmentize -g "$FNAME"
32+        fi
33+    done
34+}