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

attr interactive for core

Attribute marking a completer as interactive.

Command Type

built-in

Signature

> attr interactive {flags}

Input/output types:

inputoutput
nothingbool

Examples

Drive a terminal picker from a completer, then attach it to an argument.

> @interactive
def pick-file [token: record] {
    ls | get name | to text | ^fzf --query $token.text | lines
}

def open-file [path: string@pick-file] { open $path }

Notes

An interactive completer runs on the line-editor thread, with the terminal to itself, instead of on the background completion worker. This lets it drive a terminal picker such as fzf or input list, which need stdin and the TTY. Every other completer stays on the worker, so it never blocks the line editor and its result can be cached; only completers that must own the terminal should opt in.

The attribute only chooses where a completer runs; it does not make the command one. Attach it as usual, arg: type@name or @complete 'name'; and the completion engine calls it with the token record when you press Tab. Called directly it is an ordinary command, so declare token: record: that way pick-file foo is rejected at the call site instead of failing deep inside the body on $token.text. To try a completer by hand, get a real record from commandline complete --input.