Skip to content

Instantly share code, notes, and snippets.

@nedmas
Created September 23, 2013 10:52
Show Gist options
  • Save nedmas/6668968 to your computer and use it in GitHub Desktop.
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.
#!/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