Diff
1diff --git a/plugins/colorize/README.md b/plugins/colorize/README.md
2index 71fa87861019eb74b696d0bd8614df2e749d8586..d1f878e6219cb3d4ef26254c93f5d779bcafc163 100644
3--- a/plugins/colorize/README.md
4+++ b/plugins/colorize/README.md
5@@ -11,6 +11,12 @@ To use it, add colorize to the plugins array of your zshrc file:
6 plugins=(... colorize)
7 ```
8
9+## Styles
10+
11+Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable:
12+
13+`ZSH_COLORIZE_STYLE="colorful"`
14+
15 ## Usage
16
17 * `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
18diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh
19index bec9a2ac6d975a139e8740c49572d5409255aad0..565ba5a36e4525eb8fb91898f99ecfc2eea791fd 100644
20--- a/plugins/colorize/colorize.plugin.zsh
21+++ b/plugins/colorize/colorize.plugin.zsh
22@@ -1,6 +1,6 @@
23 # easier alias to use the plugin
24 alias ccat='colorize_via_pygmentize'
25-alias cless='colorize_via_pygmentize_less'
26+alias cless='colorize_via_pygmentize_less'
27
28 colorize_via_pygmentize() {
29 if ! (( $+commands[pygmentize] )); then
30@@ -8,36 +8,44 @@ colorize_via_pygmentize() {
31 return 1
32 fi
33
34+ # If the environment varianle ZSH_COLORIZE_STYLE
35+ # is set, use that theme instead. Otherwise,
36+ # use the default.
37+ if [ -z $ZSH_COLORIZE_STYLE ]; then
38+ ZSH_COLORIZE_STYLE="default"
39+ fi
40+
41 # pygmentize stdin if no arguments passed
42 if [ $# -eq 0 ]; then
43- pygmentize -g
44+ pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
45 return $?
46 fi
47
48 # guess lexer from file extension, or
49 # guess it from file contents if unsuccessful
50+
51 local FNAME lexer
52 for FNAME in "$@"
53 do
54 lexer=$(pygmentize -N "$FNAME")
55 if [[ $lexer != text ]]; then
56- pygmentize -l "$lexer" "$FNAME"
57+ pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME"
58 else
59- pygmentize -g "$FNAME"
60+ pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
61 fi
62 done
63 }
64
65-colorize_via_pygmentize_less() (
66+colorize_via_pygmentize_less() (
67 # this function is a subshell so tmp_files can be shared to cleanup function
68 declare -a tmp_files
69-
70+
71 cleanup () {
72 [[ ${#tmp_files} -gt 0 ]] && rm -f "${tmp_files[@]}"
73 exit
74 }
75 trap 'cleanup' EXIT HUP TERM INT
76-
77+
78 while (( $# != 0 )); do #TODO: filter out less opts
79 tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")"
80 tmp_files+=("$tmp_file")