Skip to content

Instantly share code, notes, and snippets.

@LeastFixedPoint
Created December 12, 2012 18:56
Show Gist options
  • Save LeastFixedPoint/4270519 to your computer and use it in GitHub Desktop.
Save LeastFixedPoint/4270519 to your computer and use it in GitHub Desktop.
Composable beautifier of lists of paths. Usage (e.g.): git diff HEAD^ --stat | treeify.awk
#!/usr/bin/awk -f
BEGIN { FS = ""; prev = "" }
{
prefix = ""; n = 1
while ((n <= NF) && ($n == substr(prev, n, 1))) {
if ($n == "/") { prefix = substr($0, 1, n) }
n++
}
print "\033[1;30m" prefix "\033[0m" substr($0, length(prefix)+1)
prev = $0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment