-
-
Save magik6k/17024587265b028215b2e2c3f6f8a00f to your computer and use it in GitHub Desktop.
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 | |
# 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