paulirish.git-recent/git-recent
Daniel Liuzzi 28c5002f3c Target both 32-bit & 64-bit MinGW
For example `MINGW64_NT-10.0`.
2018-04-20 11:00:58 +02:00

50 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
##
## git-recent
##
## list all local branches, sorted by last commit, formatted reall purdy
##
# Windows needs more basic format (#8, git-for-windows/git#865)
case $(uname -s) in
CYGWIN*|MINGW*|MSYS*)
branch='%(refname:short)'
spacer=' '
;;
*)
branch='%(color:yellow)%(refname:short)%(color:reset)'
spacer='%(color:black) %(color:reset)'
;;
esac
format="\
%(HEAD) \
$branch|\
%(color:bold red)%(objectname:short)%(color:reset) \
%(color:bold green)(%(committerdate:relative))%(color:reset) \
%(color:bold blue)%(authorname)%(color:reset) \
%(color:yellow)%(upstream:track)%(color:reset)
$spacer|\
%(contents:subject)
$spacer|"
lessopts="--tabs=4 --quit-if-one-screen --RAW-CONTROL-CHARS --no-init"
git for-each-ref \
--color=always \
--sort=-committerdate \
"refs/heads/" \
--format="$format" \
| column -ts '|' \
| less "$lessopts"
# The above command:
# for all known branches,
# (force coloring on this, especially since it's being piped)
# sort descending by last commit
# show local branches (change to "" to include both local + remote branches)
# apply the formatting template above
# break into columns
# use the pager only if there's not enough space