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

This commit is contained in:
John Welsh 2020-07-31 06:56:22 -07:00 committed by GitHub
parent 8755c5f101
commit 345cb99e5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -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).

View File

@ -46,7 +46,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 +62,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
}