Last active
January 4, 2022 03:30
-
-
Save carlosayam/5316969 to your computer and use it in GitHub Desktop.
Output branches description in Git (bash version)
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 | |
set -f | |
git branch | while read line; do | |
current=' ' | |
name=${line##\* } ## removes leading * for current | |
if [ ! "$name" = "$line" ]; then current='* '; fi | |
description=`git config branch.$name.description` | |
echo "$current" $name : $description | |
done |
awesome, thanks! here's a upgrade
green=`tput setaf 2`
reset=`tput sgr0`
git-branch-list() {
set -f
git branch | while read line; do
current=" "
name=${line##\* } ## removes leading * for current
if [ ! "$name" = "$line" ]; then
current="${green}* "
fi
description=`git config branch.$name.description`
if [ "$description" != "" ]; then
description=" : $description"
fi
echo "${reset}${current}${name}${description}"
done
}
@alexgorbatchev Thank you! I am astonished that git doesn't do this automatically. Thank you so much.
P.S. It disabled globbing on my system. Here's an update.
green=`tput setaf 2`
reset=`tput sgr0`
git-branch-list() {
set -f
git branch | while read line; do
current=" "
name=${line##\* } ## removes leading * for current
if [ ! "$name" = "$line" ]; then
current="${green}* "
fi
description=`git config "branch.$name.description"`
if [ "$description" != "" ]; then
description=" : $description"
fi
echo "${reset}${current}${name}${description}${reset}"
done
set +f
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credit: An alternative to gist