Created
September 23, 2013 10:52
-
-
Save nedmas/6668968 to your computer and use it in GitHub Desktop.
Simple bash script to list out the current branch and status of all git repos in sub directories.
This file contains 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 | |
GIT=$(which git) | |
SED=$(which sed) | |
PATH=${1:-$(pwd)} | |
for DIR in $PATH/* | |
do | |
if [ -d $DIR ] | |
then | |
cd $DIR | |
if $GIT rev-parse --git-dir >/dev/null 2>&1 | |
then | |
if $GIT diff --quiet 2>/dev/null >&2 | |
then | |
echo -ne "\033[00;00m$DIR \033[00;32m($($GIT branch 2>/dev/null| $SED -n '/^\*/s/^\* //p'))\n" | |
else | |
echo -ne "\033[00;00m$DIR \033[00;31m($($GIT branch 2>/dev/null| $SED -n '/^\*/s/^\* //p'))\n" | |
fi | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment