Skip to content

Instantly share code, notes, and snippets.

@fairlight1337
Last active August 8, 2016 07:24
Show Gist options
  • Save fairlight1337/84bb2643942bd497bd470e605564b301 to your computer and use it in GitHub Desktop.
Save fairlight1337/84bb2643942bd497bd470e605564b301 to your computer and use it in GitHub Desktop.
A script I put into my $PATH and use for quickly listing the currently selected branches of all subdirectories (rather than going through them one by one)
#!/bin/bash
MASTER="master"
for item in $(ls -1); do
if [ -d $item ]; then
cd $item
if [ -d .git ]; then
branch=`git rev-parse --abbrev-ref HEAD`
if [ "$branch" != "$MASTER" ]; then
color=$'\033[37;3m'
else
color=$'\033[92;3m'
fi
printf "%s%-35s : %s%s\n" $color $item $branch $'\033[39;0m'
fi
cd ..
fi
done
@fairlight1337
Copy link
Author

Colors master in light green, everything else in white.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment