From 8cb555e7a96a5a792e6094a761d3e2d57197923b Mon Sep 17 00:00:00 2001 From: August Feng Date: Tue, 5 Jul 2022 19:38:27 -0400 Subject: [PATCH] fix(colorize): support args when input is stdin --- 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 a9da6cf83..ed310d5fa 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