Created
September 27, 2017 16:04
-
-
Save sgolemon/66e72ad6f65acb77b04ff00ef5b68ff4 to your computer and use it in GitHub Desktop.
My `git branches` command
This file contains hidden or 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 | |
set -e | |
branches=$(git branch | cut -c 2-) | |
len=0 | |
for branch in $branches; do | |
if [ $len -lt ${#branch} ]; then | |
len=${#branch} | |
fi | |
done | |
current=$(git branch | grep -E '^\*' | cut -c 3-) | |
for branch in $branches; do | |
subject=$(git log -1 --format="%s" "$branch" | grep -vE '^gpg:') | |
if [ "$current" = "$branch" ]; then | |
echo -en "\e[32m" | |
fi | |
printf "%-${len}s %s\e[0m\n" "$branch" "$subject" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment