Skip to content

Instantly share code, notes, and snippets.

@MichaelAquilina
Last active June 22, 2017 13:33
Show Gist options
  • Save MichaelAquilina/8d9346a04d67ff2c2c083fb7606bbf2c to your computer and use it in GitHub Desktop.
Save MichaelAquilina/8d9346a04d67ff2c2c083fb7606bbf2c to your computer and use it in GitHub Desktop.
#! /bin/bash
if [ -n "$1" ]; then
TARGET="$1"
else
TARGET="."
fi
GREEN="$(tput setaf 2)"
RED="$(tput setaf 1)"
RESET="$(tput sgr0)"
directories="$(find "$TARGET" -name ".git" -type d)"
echo "$directories" | while read -r directory; do
NAME="$(dirname "$directory")"
pushd "$NAME" > /dev/null
STATUS="$(git status --porcelain)"
COLOR="$RED"
if [[ -z "$STATUS" ]]; then
COLOR=$GREEN
STATUS="Clean"
fi
echo "$RESET${NAME:2}: $COLOR$STATUS"
popd > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment