git alias finder (aka: git finda)

A long time ago, I had found Brett Terpstra’s One git Alias To Rule Them All. His alias, git finda [text], prints a nicely formatted table consisting of all git aliases you have defined. This worked well on Mac OSX, but the printf statements to pad/justify the alias name never worked for me on either Windows or Linux. I’ve tweaked his alias slightly and ended up with something that works on both Windows and Linux.

finda = "!grepalias() { git config --global --get-regexp alias | grep -i \"$1\" | awk -v nr=2 '{sub(/^alias\\./,\"\")};{printf \"\\033[31m%12.12s\\033[1;37m\", $1};{sep=FS};{for (x=nr; x< =NF; x++) {printf \"%s%s\", sep, $x; }; print \"\\033[0;39m\"}'; }; grepalias"