Skip to content

Instantly share code, notes, and snippets.

@itayd
Created December 15, 2010 11:40
Show Gist options
  • Save itayd/741878 to your computer and use it in GitHub Desktop.
Save itayd/741878 to your computer and use it in GitHub Desktop.
summarized git status
#!/bin/bash
grn='\e[1;32m'
red='\e[0;31m'
cyn='\e[0;36m'
rst='\e[0m'
label=
tmpfn=/tmp/.sgs.$$
git status -s --porcelain | cut -b 1,2 | sed -e "s/ /_/g" -e "s/?/U/g" >& $tmpfn
(( ! $? )) && {
fields=`cat $tmpfn | sort | uniq`
for k in $fields; do
[[ $k == "A_" || $k == "R_" ]] && label="${label}${grn}"
[[ $k == "_D" || $k == "_M" ]] && label="${label}${red}"
[[ $k == "UU" ]] && label="${label}${cyn}"
label="${label}$k`cat $tmpfn | grep -x $k | wc -l` $rst"
done
}
rm -f $tmpfn
[[ -n $label ]] && {
echo -e $label
}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment