Created
September 12, 2013 12:17
-
-
Save sunny/6536434 to your computer and use it in GitHub Desktop.
Git branches ordered by freshness.
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/sh | |
# Via http://stackoverflow.com/a/18213567/311657 | |
current_branch="$(git symbolic-ref --short -q HEAD)" | |
git for-each-ref --sort=committerdate refs/heads \ | |
--format='%(refname:short)|%(objectname:short)|%(committerdate:relative)|%(authorname)|%(subject)|%(upstream:short)' \ | |
| while IFS='|' read refname objectname date authorname subject upstream | |
do | |
reverse='\x1b[7m' | |
reset='\e[0m' | |
green='\e[32m' | |
red='\e[31m' | |
yellow='\e[33m' | |
blue='\e[34m' | |
cyan='\e[36m' | |
start=' ' | |
if [[ $refname = $current_branch ]]; then | |
start='\x1b[7m* ' | |
fi | |
printf "$cyan$start%-55s$reset $yellow%s $green%s $blue%s: $reset%s $cyan%s\\n" "$refname" "$objectname" "$authorname" "$date" "$subject" "$upstream" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this file in your
~/bin
, then in your~/.gitconfig
aliases, addbr = !git-br
.You can then: