Last active
December 20, 2015 15:29
-
-
Save gonzaloserrano/6154585 to your computer and use it in GitHub Desktop.
Execute git commands in all vendors. Display git repo name, branch, repo status (modified, committed, added and untracked files) and file path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# modify the find target directory as needed | |
#legend | |
echo -e " \033[1;31;m● Modified \033[32;m● Committed \033[34;m● Added \033[1;30;m● Untracked" | |
echo | |
i=0 | |
for VENDOR in `find vendor/socialpoint -type d -name .git`; do | |
let i="$i+1" | |
VENDORDIRNAME=`dirname $VENDOR` | |
REPONAME=`git --git-dir=$VENDOR --work-tree=$PWD/$VENDORDIRNAME config --get remote.origin.url 2>/dev/null | awk -F '/' '{print $2}' | sed 's/.git//'` | |
BRANCH=`git --git-dir=$VENDOR --work-tree=$PWD/$VENDORDIRNAME rev-parse --abbrev-ref HEAD` | |
case "$BRANCH" in | |
"master") | |
BRANCH_COLOR="38;05;39" | |
;; | |
"develop") | |
BRANCH_COLOR="38;05;27" | |
;; | |
"HEAD") | |
BRANCH_COLOR="38;05;33" | |
;; | |
*) | |
BRANCH_COLOR="38;05;03" | |
;; | |
esac | |
STATUS="" | |
[[ $(git --git-dir=$VENDOR --work-tree=$PWD/$VENDORDIRNAME status --porcelain 2>/dev/null| grep "^ M") != "" ]] && STATUS="$STATUS\033[1;31;m●" | |
[[ $(git --git-dir=$VENDOR --work-tree=$PWD/$VENDORDIRNAME status --porcelain 2>/dev/null| egrep "^(M| M)") != "" ]] && STATUS="$STATUS\033[32;m●" | |
[[ $(git --git-dir=$VENDOR --work-tree=$PWD/$VENDORDIRNAME status --porcelain 2>/dev/null| grep "^A") != "" ]] && STATUS="$STATUS\033[34;m●" | |
[[ $(git --git-dir=$VENDOR --work-tree=$PWD/$VENDORDIRNAME status --porcelain 2>/dev/null| grep "^??") != "" ]] && STATUS="$STATUS\033[1;30;m●" | |
if [ ! -z $STATUS ]; then | |
STATUS="\033[0;m[$STATUS\033[0;m] " | |
fi | |
printf "%2d) " $i | |
echo -e "\033[38;5;46m$REPONAME \033[${BRANCH_COLOR}m($BRANCH) $STATUS\033[0;m> \033[38;5;198m$VENDORDIRNAME\033[0;m" | |
if [ ! -z "$@" ]; then | |
echo && git --git-dir=$VENDOR --work-tree=$PWD/$VENDORDIRNAME $@ 2>/dev/null && echo | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment