From ad889065af104e6d69f54bb2d474abd666ed11fa Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 4 Dec 2022 17:47:48 -0800 Subject: [PATCH] tools: gtree --- tools/gtree | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 tools/gtree diff --git a/tools/gtree b/tools/gtree new file mode 100755 index 000000000..2f3677634 --- /dev/null +++ b/tools/gtree @@ -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