tui tree for viewers
Add a tree for nested records or a directory walk.
Command Type
built-in
Signature
> tui tree {flags} (source)
Flags
--title {string}: Border title, in place of the widget's name. Counts, state, or the previewed file follow in parentheses.--border {string}: Border lines, named liketable --theme(rounded, double, heavy, ...).--walk: Expand directories on disk when a node is opened.--column {string}: Path/name column (default name).--id {string}: Widget id.--focus: Start with this widget focused.--data {any}: Data for this widget alone, instead of the outer pipeline's. Not with --from or a closure.--from {string}: Id of the table, tree, or select whose highlighted row drives this widget.--on-select {closure(any)}: Hook run when the highlighted row changes; receives the state record.--multi, -m: Space toggles rows; the selection is the checked rows.
Parameters
source: Closure over the highlighted row of --from, or of the nearest other table, tree, or select, whose output is this tree's data.
Input/output types:
| input | output |
|---|---|
| nothing | tui |
| tui | tui |
| any | tui |
Examples
Nested record as a tree
> {a: {b: 1, c: 2}, d: [3, 4]} | tui tree | tui debug | get screenDirectory walk next to a preview
> ls | tui split [(tui tree --walk) (tui preview)] | tui runNotes
Up/Down move. Right or l expands, Left or h collapses. Enter submits the selected node; with --multi, Space checks nodes. --walk treats type == dir rows as folders and lists them on expand; --column names the path column for that walk. A tui preview or a --from widget next to this tree follows the selected node.