summaryrefslogtreecommitdiff
path: root/plugins/colorize
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/colorize')
-rw-r--r--plugins/colorize/README.md8
-rw-r--r--plugins/colorize/colorize.plugin.zsh9
2 files changed, 13 insertions, 4 deletions
diff --git a/plugins/colorize/README.md b/plugins/colorize/README.md
index ee4ab8036..405bb6d39 100644
--- a/plugins/colorize/README.md
+++ b/plugins/colorize/README.md
@@ -38,6 +38,14 @@ Pygments offers multiple styles. By default, the `default` style is used, but yo
ZSH_COLORIZE_STYLE="colorful"
```
+### Chroma Formatter Settings
+
+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:
+
+```
+ZSH_COLORIZE_CHROMA_FORMATTER=terminal256
+```
+
## Usage
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh
index 6ed9739fa..8ea98f80a 100644
--- a/plugins/colorize/colorize.plugin.zsh
+++ b/plugins/colorize/colorize.plugin.zsh
@@ -6,7 +6,8 @@ alias cless="colorize_less"
ZSH_COLORIZE_PLUGIN_PATH=$0:A
colorize_check_requirements() {
- local available_tools=("chroma" "pygmentize")
+ local -a available_tools
+ available_tools=("chroma" "pygmentize")
if [ -z "$ZSH_COLORIZE_TOOL" ]; then
if (( $+commands[pygmentize] )); then
@@ -46,7 +47,7 @@ colorize_cat() {
if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
else
- chroma --style="$ZSH_COLORIZE_STYLE"
+ chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
fi
return $?
fi
@@ -62,7 +63,7 @@ colorize_cat() {
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
fi
else
- chroma --style="$ZSH_COLORIZE_STYLE" "$FNAME"
+ chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$FNAME"
fi
done
}
@@ -95,7 +96,7 @@ colorize_less() {
# which assumes that his LESSOPEN has been executed.
local LESSCLOSE=""
- LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" less "$@"
+ LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" command less "$@"
}
if [ -t 0 ]; then