tui preview for viewers
Command Type
built-in
Signature
> tui preview {flags} (transform)
Flags
--from {string}: Table, tree, or select id to follow.--max-bytes {int}: Maximum bytes to read from a file (default 65536).--id {string}: Widget id.--focus: Start with this widget focused.
Parameters
transform: No parameters: transform file text ($in). One parameter: produce text from the row.
Input/output types:
| input | output |
|---|---|
| nothing | tui |
| tui | tui |
| any | tui |
Examples
File list on the left, highlighted contents on the right
> ls | tui split [(tui table) (tui preview { nu-highlight })] | tui runPreview a value from the row instead of a file
> $env.config.keybindings | tui split [(tui table) (tui preview {|row| $row.event | to nuon })] | tui runNotes
Without a closure, the row's name (or the row itself when it is a string) is read as a file path, up to --max-bytes. Directories and binary files show a short note.
A closure with no parameters transforms that file text: it receives the contents as $in, with content_type in pipeline metadata, so { nu-highlight } colors source files.
A closure with one parameter is the source: it receives the selected row and whatever it returns is shown. Nothing is read from disk, so any column or computed value can be previewed: {|row| $row.event | to nuon } or {|row| open --raw $row.path }.
The preview follows the focused list, else the nearest one in the same container. --from names one explicitly.