Skip to content

Instantly share code, notes, and snippets.

@magik6k
Created June 18, 2017 15:59
Show Gist options
  • Save magik6k/17024587265b028215b2e2c3f6f8a00f to your computer and use it in GitHub Desktop.
Save magik6k/17024587265b028215b2e2c3f6f8a00f to your computer and use it in GitHub Desktop.
#!/bin/bash
# ls command printing status/branch of git subdirectories
# WTFNMFPL
if [ "$#" = 1 ]; then
cd $1
fi
for repo in $(ls); do
cd $repo 2>/dev/null || continue
if [ ! -d .git ]; then
cd ..
echo $repo
continue
fi
RES="$repo "
if git diff-index --quiet HEAD --; then
RES=$RES"\e[32mCLEAN\e[39m"
else
RES=$RES"\e[31mDIRTY\e[39m"
fi
BRANCH=$(git rev-parse --abbrev-ref HEAD)
RES="$RES $([[ $BRANCH = "master" ]] && printf "\e[32m" || printf "\e[33m" )$BRANCH\e[39m"
echo -e $RES
cd ..
done | column -s ' ' -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment