diff options
author | Robby Russell <robby@planetargon.com> | 2013-04-23 19:53:33 -0700 |
---|---|---|
committer | Robby Russell <robby@planetargon.com> | 2013-04-23 19:53:33 -0700 |
commit | b01a48d05644a08336c3c0fd1511b564593d69e1 (patch) | |
tree | 5f69a28b68a32e74d687989390d9c37dcfb01924 /plugins/colorize/colorize.plugin.zsh | |
parent | 51d7d573315aa40ca21543865b463e2199a57ebd (diff) | |
parent | 07738ea86330b7b77127fc6f18474b3da2c6ecec (diff) | |
download | zsh-b01a48d05644a08336c3c0fd1511b564593d69e1.tar.gz zsh-b01a48d05644a08336c3c0fd1511b564593d69e1.tar.bz2 zsh-b01a48d05644a08336c3c0fd1511b564593d69e1.zip |
Merge pull request #1714 from f0y/07738ea86330b7b77127fc6f18474b3da2c6ecec
Colorize plugin
Diffstat (limited to 'plugins/colorize/colorize.plugin.zsh')
-rw-r--r-- | plugins/colorize/colorize.plugin.zsh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh new file mode 100644 index 000000000..0696607d9 --- /dev/null +++ b/plugins/colorize/colorize.plugin.zsh @@ -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 +}
\ No newline at end of file |