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

commandline complete for core

Complete a string using the default completions.

Command Type

built-in

Signature

> commandline complete {flags}

Flags

  • --detailed, -d: Output completions as records, in the format expected from custom completers.
  • --input, -i: Output the record a completer would receive here ({token, place, buffer}), instead of completions.
  • --type {string}: Restrict completions to one built-in source (directory, path, glob, command, variable, or env-var), so a completer can compose the engine's own sources with its results.

Input/output types:

inputoutput
nothingoneof<list<string>, list<record>, record>
stringoneof<list<string>, list<record>, record>

Examples

List completions for command names.

> def my-bar [] {}; def my-baz [] {}; 'my-' | commandline complete
╭───┬────────╮
│ 0 │ my-bar │
│ 1 │ my-baz │
╰───┴────────╯

List completions for flags for a command.

> def cmd [--flag(-f): string] {}; 'cmd -' | commandline complete
╭───┬────────╮
│ 0 │ --flag │
│ 1 │ -f     │
╰───┴────────╯

Complete filepath or glob arguments.

> './' | commandline complete --type path

Extend builtin completions for the current commandline.

> commandline complete | append 'foo'

Compose a built-in source inside a completer: the engine's command names beside your own.

> def comp [token: record] { [my-alias] ++ ($token.text | commandline complete --type command) }

Return fallback: true to add completions beside the built-in ones rather than replacing them.

> def comp [token: record] { {completions: [my-preset], fallback: true} }

Inspect what a completer would be handed at the cursor, including the argument's declared shape.

> 'cd ma' | commandline complete --input | get place.shape

Notes

This command can be used to obtain the completions that Nushell would normally provide for the given commandline contents. Completions will be provided as if the cursor is placed at the end of the given string.

If no input is provided, the current commandline contents will be used instead.

With --input, the record a completer would receive at that position is returned instead of completions, which is the supported way to develop and test a completer from inside Nushell.