tui for viewers
Command Type
built-in
Signature
> tui {flags}
Input/output types:
| input | output |
|---|---|
| nothing | string |
Examples
List TUI subcommands
> tuiNotes
You must use one of the following subcommands. Using this command as-is will only produce this help message.
Builders (tui table, tui split, ...) append widgets to a tui value. tui run shows it and returns one record: {action, focused, selected, page, values, rows, live}, where values holds every widget's state by id. tui debug returns the same record plus the painted screen and the resolved layout, for scripts and tests.
Data: a value piped into a builder is the shared data list. Builders never read a stream: a list stream, a range, or an external command's output is kept in the tui value and read while the TUI runs, so its rows appear as they are produced (1.. | each {|n| sleep 1sec; $n} | tui log). A stream keeps its newest 100k rows (older rows are dropped in batches, so up to 12.5k more may show). When the TUI closes, a stream still producing is stopped: an external command piped straight into a builder at once, and one behind other commands (^tail -f app.log | lines | tui log) at once in an interactive shell, elsewhere the next time it writes. Nushell code in a stream (an each closure) finishes the row it is on, and what it prints while the TUI runs lands on the TUI's screen. A tui value saved with let reads its stream the first time it runs; if that run read it to the end, later runs show the same rows. A widget can have its own rows with --data, or by piping into it inside a container's child list: tui split [(ls | tui table) (ps | tui table)]. A widget can also follow the highlighted row of a table, tree, or select. A closure on tui table, tree, log, progress, or label turns that row into what the widget shows, and --from <id> picks which one to follow; without it the widget follows the focused one, else the nearest, else one on another tab page, but never one that follows it back. --from without a closure shows the row itself. A widget with nothing to follow is an error when the TUI starts, and --data cannot be combined with --from or a closure.
Hooks: tui bind, menu actions, tui button, --on-select, and the tui run refresh closure all receive the state record and may return nothing, a new data list, or {action: submit|quit, selected: ...}. A new data list replaces the shared data for the rest of the run: a piped stream no longer adds to it.
Layout: tui split --sizes [30% 1fr] arranges children; tui box groups them with a border; tui tab makes a page. Bordered widgets take --title to rename their border (tui table --title files shows files (12)); tui label --titlebar fills the bar at the top. Colors come from $env.config.tui; --border on a widget or $env.config.tui.border_type picks its border lines by table --theme name (rounded, double, heavy, ...).
Subcommands:
| name | description | type |
|---|---|---|
tui bind | Run a hook when a key is pressed anywhere in the TUI. | built-in |
tui box | Group widgets inside a titled, bordered box. | built-in |
tui button | Add a button that runs a hook, or submits its label, when activated. | built-in |
tui debug | Render a TUI without a terminal and return the screen plus the resolved layout, focus order, and pages. | built-in |
tui label | Add static text: inline, or as the title bar (--titlebar) or status bar (--status). | built-in |
tui log | Add an append-only log view. Streamed rows appear at the bottom. | built-in |
tui menu | Add a menu bar with mnemonics, dropdown items, and actions. | built-in |
tui preview | Show text for the selected table, tree, or select row. Arrow keys stay on the source. | built-in |
tui progress | Add a progress bar. | built-in |
tui run | Run a composed TUI until the user quits or submits a selection. | built-in |
tui search | Add a search box that filters tables, logs, trees, and selects as you type. | built-in |
tui select | Add a radio list of items, or a checkbox list with --multi. | built-in |
tui split | Lay out child widgets side by side (or stacked with --vertical) with draggable dividers. | built-in |
tui tab | Group widgets as a page in the tab bar. | built-in |
tui table | Add a navigable table. Pipeline rows become the rows; scalars show as one item column. | built-in |
tui textbox | Add an editable text field. Tab to focus it, then type. | built-in |
tui tree | Add a tree for nested records or a directory walk. | built-in |