Skip to content

Instantly share code, notes, and snippets.

@alorma
Forked from kchodorow/branch.sh
Last active August 29, 2015 14:06
Show Gist options
  • Save alorma/859fa96eac09e31be6fd to your computer and use it in GitHub Desktop.
Save alorma/859fa96eac09e31be6fd to your computer and use it in GitHub Desktop.
#!/bin/bash
# Shows branches with descriptions
branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||')
for branch in $branches; do
last_used=$(git show --pretty=format:"%Cgreen%cr%Creset" $branch | head -1)
desc=$(git config branch.$branch.description)
if [ $branch == $(git rev-parse --abbrev-ref HEAD) ]; then
branch="*\t$last_used\t\033[0;32m$branch\033[0m"
else
branch="\t$last_used\t$branch"
fi
echo -e "$branch \033[0;36m$desc\033[0m"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment