345cb99e5bbdd404e2da0d0e294623eccc130c27

Author
John Welsh <john.welsh@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

colorize: add $ZSH_COLORIZE_CHROMA_FORMATTER config env var (#8824)

Diff

 1diff --git a/plugins/colorize/README.md b/plugins/colorize/README.md
 2index ee4ab80360b188577d6c9f7dc6594098d4ed9cbe..405bb6d39fe740b68180150a38afe346e4cb0e36 100644
 3--- a/plugins/colorize/README.md
 4+++ b/plugins/colorize/README.md
 5@@ -38,6 +38,14 @@ Pygments offers multiple styles. By default, the `default` style is used, but yo
 6 ZSH_COLORIZE_STYLE="colorful"
 7 ```
 8 
 9+### Chroma Formatter Settings
10+
11+Chroma supports terminal output in 8 color, 256 color, and true-color. If you need to change the default terminal output style from the standard 8 color output, set the `ZSH_COLORIZE_CHROMA_FORMATTER` environment variable:
12+
13+```
14+ZSH_COLORIZE_CHROMA_FORMATTER=terminal256
15+```
16+
17 ## Usage
18 
19 * `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
20diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh
21index 6ed9739fadba3e9cf611b9e1611101f3f4e042f3..80b69190f0d0022ffe321939473778ba2bd752b0 100644
22--- a/plugins/colorize/colorize.plugin.zsh
23+++ b/plugins/colorize/colorize.plugin.zsh
24@@ -46,7 +46,7 @@ colorize_cat() {
25         if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
26             pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
27         else
28-            chroma --style="$ZSH_COLORIZE_STYLE"
29+            chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
30         fi
31         return $?
32     fi
33@@ -62,7 +62,7 @@ colorize_cat() {
34                 pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
35             fi
36         else
37-            chroma --style="$ZSH_COLORIZE_STYLE" "$FNAME"
38+            chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$FNAME"
39         fi
40     done
41 }