Skip to content

Instantly share code, notes, and snippets.

@aaronmccall
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronmccall/9897788 to your computer and use it in GitHub Desktop.
Save aaronmccall/9897788 to your computer and use it in GitHub Desktop.
bash script to show git changed/new status of repos in a directory
#!/bin/bash
reset=$(tput sgr0)
green=$(tput setaf 2)
cyan=$(tput setaf 6)
magenta=$(tput setaf 5)
bold=$(tput bold)
for arg in $( ls | egrep '^dsm-' ); do
(
cd "$arg"
if [ -e "./package.json" ]; then
ver=$(cat package.json | grep version | awk '{print substr($2, 2, 5)}')
else
ver="N/A"
fi
branch=$(git branch | grep \* | awk '{print $2}')
echo "${cyan}$arg${reset} @ ${magenta}${ver}${reset} # $green$branch$reset"
if git status | egrep -q '^.\t.'; then
if git status | egrep -q '^#\tmodified'; then
echo "${reset}Changed:"
tput setaf 3 && git status | egrep '^#\tmodified' | awk '{printf(" %s\n", $3)}'
echo "$reset "
fi
if git status | grep -q Untracked; then
echo "New:"
tput setaf 3 && git status | egrep '^#\t.' | awk '{printf(" %s\n", $2)}'
echo "$reset "
fi
else
echo "$reset ** clean **"
echo " "
fi
)
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment