Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

tui preview for viewers

Show text for the selected table, tree, or select row. Arrow keys stay on the source.

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:

inputoutput
nothingtui
tuitui
anytui

Examples

File list on the left, highlighted contents on the right

> ls | tui split [(tui table) (tui preview { nu-highlight })] | tui run

Preview a value from the row instead of a file

> $env.config.keybindings | tui split [(tui table) (tui preview {|row| $row.event | to nuon })] | tui run

Notes

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.