tools: gtree

This commit is contained in:
Simon Michael 2022-12-04 17:47:48 -08:00
parent 934f0e3cd6
commit ad889065af

17
tools/gtree Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# gtree [REGEX] - list [a matched subset of] git files as an indented tree.
# Because the other tools suck more. Only lists files, not directories.
# REGEX is a case-insensitive grep regexp matching the relative file paths.
#
# gtree
# gtree yaml
# gtree '(^|/)((bsd)?m|sh)ake'
REGEX="${1:-.}"
# list git-tracked files
# keep only the paths matching REGEX
# convert paths list to an indented tree
git ls-files | \
grep -iE "$REGEX" | \
sed -e 's/\//:/g' -e 's/^/account /' | hledger -f- accounts -t