From ade8198472a5aaf04e806490a6382987f7015af8 Mon Sep 17 00:00:00 2001 From: pablopunk Date: Mon, 6 Jul 2026 08:03:55 +0000 Subject: [PATCH] [ai] Use porcelain git status parsing --- bashy | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/bashy b/bashy index 6184784..8e04b4d 100755 --- a/bashy +++ b/bashy @@ -25,13 +25,22 @@ symbol_ahead="\x01\033[32m\x02↑" # green delete=0; change=0; new=0; ahead=0; behind=0 -for line in $gitstatus; do - [[ $line =~ ^D ]] && delete=1 - [[ $line =~ ^M ]] && change=1 - [[ $line =~ ^\?\? ]] && new=1 - [[ $line =~ behind ]] && behind=1 - [[ $line =~ ahead ]] && ahead=1 -done +while IFS= read -r line; do + case "$line" in + '## '*) + [[ $line == *'behind '* ]] && behind=1 + [[ $line == *'ahead '* ]] && ahead=1 + ;; + '?? '*) + new=1 + ;; + *) + status="${line:0:2}" + [[ $status == *D* ]] && delete=1 + [[ $status == *M* ]] && change=1 + ;; + esac +done <<< "$gitstatus" [ $delete -eq 1 ] && symbols="$symbols$symbol_delete" [ $change -eq 1 ] && symbols="$symbols$symbol_change"