Last active
August 29, 2015 14:11
-
-
Save jeenuv/3145db36eb2a27ba022a to your computer and use it in GitHub Desktop.
Print descriptions of all local branches
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 | |
| # For each branch in the repository, get the branch description from | |
| # Git config, and print in a neat fashion | |
| [ -d .git ] || exit 1 | |
| git for-each-ref refs/heads --format='%(refname:short)' | grep -v '\.stgit' | | |
| xargs bash -c ' | |
| head="$(git symbolic-ref --short HEAD)" | |
| for br; do | |
| desc=$(git config --get branch.$br.description | head -n1 ) | |
| if [ "$head" = "$br" ]; then | |
| # Print the current branch in green foreground | |
| # | |
| # Terminal control characters are counted for calculating width of field, | |
| # but does not appear as characters in the terminal output. Therefore it | |
| # affects alignment To balance "missing" characters, we add 5 trailing | |
| # white spaces per `tput` to the branch field | |
| printf " * %-60s%-10s%s\n" "$(tput setaf 2)$br$(tput setaf 9)" "" "$desc" | |
| else | |
| printf " * %-60s%s\n" "$br" "$desc" | |
| fi | |
| done' bash | |
| # vim:set tw=80 sw=2: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment