#!/bin/bash # Usage: git-branch-dates # Show git branches by date - useful for showing active branches # Inspired by: # - http://www.commandlinefu.com/commands/view/2345/show-git-branches-by-date-useful-for-showing-active-branches # - https://stackoverflow.com/a/30076212 format='%(HEAD) %(color:green)%(refname:short)%(color:reset)|%(color:bold black)%(committerdate:relative)%(color:reset)' if [[ "$1" = "-v" || "$1" = "-vv" ]]; then shift format="$format"'|%(color:yellow)%(objectname:short)%(color:reset) %(contents:subject)' fi git branch \ --color=always \ --sort=-committerdate \ --format="$format" \ $* | column -ts'|'