From 99c99954e9682f49ec2da74c0360849bdaeb739b Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 17 Jan 2023 01:41:38 +0100 Subject: [PATCH] git:last-changed: Pass -p and smart --color flag --color=auto breaks as `ls` is always piped. Test stdout of the whole script to determine a sensible value for the flag. --- .config/zsh/autoload/git/git-last-changed | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.config/zsh/autoload/git/git-last-changed b/.config/zsh/autoload/git/git-last-changed index db06540..f6b7660 100755 --- a/.config/zsh/autoload/git/git-last-changed +++ b/.config/zsh/autoload/git/git-last-changed @@ -5,7 +5,10 @@ # sort the entries by the commits date and time to see the most recent changed # files/folders at the bottom. -ls -1 "$@" \ +local color_set +[ -t 1 ] && color_set=always || color_set=never + +ls -1p --color="$color_set" "$@" \ | while read -r line; do sanitized_line="$(sed 's/\x1b[^m]*m//g' <<<"$line")" git_info="$(git log -1 --format=$'%ci\t%s' "$sanitized_line")"