August Feng <46177585+augustfengd@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date
Message
fix(colorize): support args when input is stdin (#11038)
Co-authored-by: August Feng <au.fengster@gmail.com>
Diff
1diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh
2index 12841e0ee9e4d55d151024225ece63d8c2dbeeed..c49acd864706d505dabb61cb0a8be93131076183 100644
3--- a/plugins/colorize/colorize.plugin.zsh
4+++ b/plugins/colorize/colorize.plugin.zsh
5@@ -42,12 +42,12 @@ colorize_cat() {
6 ZSH_COLORIZE_STYLE="emacs"
7 fi
8 9- # Use stdin if no arguments have been passed.
10- if [ $# -eq 0 ]; then
11+ # Use stdin if stdin is not attached to a terminal.
12+ if [ ! -t 0 ]; then
13 if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
14 pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
15 else
16- chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
17+ chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$@"
18 fi
19 return $?
20 fi