From 9f0ffcb6ca13f58db642647cb1675211db62e902 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 17 Jan 2023 01:39:43 +0100 Subject: [PATCH] git:last-changed: Support ANSI escape sequences When passing --color to `ls` and the entry were colored, git would not return a commit due to the escape sequences. --- .config/zsh/autoload/git/git-last-changed | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.config/zsh/autoload/git/git-last-changed b/.config/zsh/autoload/git/git-last-changed index aecdd55..db06540 100755 --- a/.config/zsh/autoload/git/git-last-changed +++ b/.config/zsh/autoload/git/git-last-changed @@ -7,7 +7,8 @@ ls -1 "$@" \ | while read -r line; do - git_info="$(git log -1 --format=$'%ci\t%s' "$line")" + sanitized_line="$(sed 's/\x1b[^m]*m//g' <<<"$line")" + git_info="$(git log -1 --format=$'%ci\t%s' "$sanitized_line")" printf "%s\t%s\n" "$line" "$git_info" done \ | sort -r -t$'\t' -k2,2 \