attr interactive for core
Command Type
built-in
Signature
> attr interactive {flags}
Input/output types:
| input | output |
|---|---|
| nothing | bool |
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.