From 47767bd03cae60bc4b3d8ab4ba8e6b6c78bc17ed Mon Sep 17 00:00:00 2001 From: August Feng <46177585+augustfengd@users.noreply.github.com> Date: Sun, 11 Aug 2024 14:01:39 -0400 Subject: [PATCH] fix(colorize): support args when input is stdin (#11038) Co-authored-by: August Feng --- plugins/colorize/colorize.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 12841e0ee..c49acd864 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -42,12 +42,12 @@ colorize_cat() { ZSH_COLORIZE_STYLE="emacs" fi - # Use stdin if no arguments have been passed. - if [ $# -eq 0 ]; then + # Use stdin if stdin is not attached to a terminal. + if [ ! -t 0 ]; then if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then pygmentize -O style="$ZSH_COLORIZE_STYLE" -g else - chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" + chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$@" fi return $? fi