Skip to content

Instantly share code, notes, and snippets.

@johnweldon
Created March 13, 2015 23:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnweldon/0a9ee3c9406fab2ac93b to your computer and use it in GitHub Desktop.
Save johnweldon/0a9ee3c9406fab2ac93b to your computer and use it in GitHub Desktop.
#!/bin/bash
read -r -d '' AWK <<EOF
{
date=\$1;
refname=\$2;
subject=substr(\$3,1,72);
sha=\$4;
len=split(refname, ref, "/");
reset="\033[0m";
red="\033[0;31m";
green="\033[0;32m";
yellow="\033[0;33m";
cyan="\033[0;36m";
simple=red "%15s" green " %-30s" cyan " %15s" yellow " %s" reset " %s\n";
cmplex=red "%15s" green " %-30s" cyan " %15s" yellow " %s" reset " %s\n";
if(len<2) {
printf simple,"----",ref[1],date,sha,subject;
} else {
printf cmplex,ref[1],ref[2],date,sha,subject;
}
}
EOF
git for-each-ref --sort=committerdate --format='%(committerdate:relative)%09%(refname:short)%09%(subject)%09%(objectname:short)' | awk -F'\t' "$AWK"
@johnweldon
Copy link
Author

Shell script to display all your branches, local and remote, oldest to newest with the relative time of the last commit, colorized for bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment