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 menu for viewers

Add a menu bar with mnemonics, dropdown items, and actions.

Command Type

built-in

Signature

> tui menu {flags} (items)

Flags

  • --id {string}: Widget id.
  • --focus: Start with this widget focused.

Parameters

  • items: Bar entries: strings or {name, items?, action?} records.

Input/output types:

inputoutput
nothingtui
tuitui
anytui

Examples

A plain bar; Enter submits the item name

> tui label --title "Editor" | tui menu ["&File" "&Edit" "&View"] | tui table | tui debug --keys "alt+e,enter" | get selected

Dropdowns with actions that reload the table, and a Quit entry that submits

> ls | tui menu [{name: "&File", items: [{name: "&Reload", action: {|| ls }} "&Quit"]} {name: "&View", items: [{name: "&Sizes", action: {|| ls | sort-by size }}]}] | tui table | tui run

Notes

Each entry is a string, or a record {name, items?, action?}. items is a list of the same shape and opens as a dropdown; action is a hook closure.

Mnemonics: & before a letter in a name picks it ("&File" shows as File with F underlined); otherwise the first letter is used. Alt+letter opens that bar item from anywhere except a text field. Inside an open dropdown, the letter alone picks the item. Left/Right (or h/l) move along the bar, Down/Enter open a dropdown, Up/Down move inside it, Esc closes it.

Activating an item with an action runs it as a hook: it receives the state record, a returned value replaces the data list, {action: submit|quit} ends the TUI, and an error goes to the status bar. Activating an item without an action submits it: selected is {menu: "File", item: "Open", row: <highlighted row>} for a dropdown entry, or the bar item's name.

The menu is top-level chrome and cannot be nested in tui split or tui box.