Maybe this is not super relevant, but my favorite hack is that any tree-like structure like this can be browsed with ncdu. Here's a gist for breaking down redis traffic by command for example:
<a href="https://gist.github.com/petethepig/0f33c910fb2edad8969a5775e23bb99f" rel="nofollow">https://gist.github.com/petethepig/0f33c910fb2edad8969a5775e...</a>
Author here: Often I have to digest log files and lists of Azure resource names. I prefer to work with hierarchies of things, so I wrote this simple filter. Turns out to quite handy, especially when combined with awk and its friends.
Neat. I'll add this to my toolbox.<p>Somewhat unrelated: I discovered some time ago that the column command (from util-linux) can print trees of hierarchical data (up to 2 levels deep).<p>From the man page:<p><pre><code> $ echo -e '1 0 A\n2 1 AA\n3 1 AB\n4 2 AAA\n5 2 AAB' | column --tree-id 1 --tree-parent 2 --tree 3
1 0 A
2 1 |-AA
4 2 | |-AAA
5 2 | `-AAB
3 1 `-AB
</code></pre>
column(1): <a href="https://github.com/karelzak/util-linux/blob/master/text-utils/column.1.adoc#examples" rel="nofollow">https://github.com/karelzak/util-linux/blob/master/text-util...</a>
Awesome. You really nailed it. In my experience the output for spreadsheets turns out to be key so good job highlighting that (<a href="https://github.com/birchb1024/frangipanni#output-for-spreadsheets" rel="nofollow">https://github.com/birchb1024/frangipanni#output-for-spreads...</a>).<p>One suggestion: it may help to generalize the newline as the node separator. You may already be doing this (my go is rusty) but instead of <a href="https://github.com/birchb1024/frangipanni/blob/7543b4ee15ae7f0491e1212a43b7fc61acc7e00a/frangipanni.go#L158" rel="nofollow">https://github.com/birchb1024/frangipanni/blob/7543b4ee15ae7...</a> be able to override the "newline" as the node separator, like you've done with the "spacer" param.<p>What do you do when the same line is encountered?
This is really very nice and useful! I read through the examples and thought about something that would be a good addition and then see that “-skip” was just implemented! I can skip (pun intended) using an additional layer of cut or awk because of this.<p>The detailed examples are great too, showing different use cases and features.<p>Thank you very much for creating this tool and sharing it.
TIL from the README, you can insert `img` tags into a markdown file, and github will honor the align tag, etc<p>```<p><img src="frangipanni.jpg" alt="A Tree" width="200" align="right"><p>```
I love what it does for log files. Abbreviated example from the README:<p><pre><code> May 10 03:17:06 localhost systemd: Removed slice User Slice of root.
May 10 03:17:06 localhost systemd: Stopping User Slice of root.
</code></pre>
becomes:<p><pre><code> May 10
03:17:06 localhost systemd
: Removed slice User Slice of root
: Stopping User Slice of root</code></pre>
Seen this about 50 years ago. It was method of saving expensive Teletype ink ribbons. Instead of printing same repeating messages on mainframe log, it printed only those parts that were different from previous line.<p>And of course empty line was "ditto". Except this wasted paper and was later replaced with "...".
There is also<p><pre><code> tree --fromfile
</code></pre>
e.g.<p><pre><code> echo a/b1 a/b2/c | xargs -n1 | tree --fromfile
.
└── a
├── b1
└── b2
└── c
2 directories, 2 files</code></pre>
In retrospect, it’s not clear to me why I somehow expected this project to be something more literally arboreal. I even got my hopes up further when I clicked the link and saw that photo of plumerias.<p>Yet, this project is cool enough that I’m not even disappointed.
I've been thinking about making something like this for a while, this is great!<p>I always thought it was weird that "do one thing and one thing well" stopped short of dealing with tree representations on the commandline.
Looks nice. Perhaps a next step could be an ncurses program that allows you to fold/unfold the trees at arbitrary places, and select entries to reveal their full path (useful for copy+paste).
I find I think about things a lot in tree structures, documentation, todo lists, technical information. I’m really keen to give this a go in my work. Thanks!