commandline complete for core
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:
| input | output |
|---|---|
| nothing | oneof<list<string>, list<record>, record> |
| string | oneof<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 pathExtend 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.shapeNotes
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.