Skip to content

nf completion

Print the script that completes nf in your shell: commands, options, settings and app inputs.

Synopsis

nf completion bash|zsh|fish

Installing

Install the script once, where your shell loads completions from:

# bash
nf completion bash > ~/.local/share/bash-completion/completions/nf

# zsh: into a directory of $fpath, or evaluated from ~/.zshrc
nf completion zsh > "${fpath[1]}/_nf"
eval "$(nf completion zsh)"

# fish
nf completion fish > ~/.config/fish/completions/nf.fish

Run it again after upgrading nf, so the script matches it.

What it completes

Beyond commands, options and their values:

  • App inputs. ++ offers the inputs the app takes (--app's app, else every configured app's): ++env=, then ++env= offers its choices (a Literal, an Enum, true/false). A bool input is also offered alone (++debug, true). A secret is never offered: it is not given on the command line. ++@ completes files of inputs, and a path-typed input completes paths. See nf vars.
  • Settings written after the command. nf apply --graph-lease-t completes to --graph-lease-ttl, and a setting's choices (--anyio-backend, --recovery-strategy) complete too, wherever on the line the setting is. See Settings.
  • Apps. --app offers the configured apps; nf lint --app their specs.

A value that goes on (++env=, a directory) gets no space after it.

How it works

The script calls nf to complete each word, with the words on the line (COMP_WORDS, COMP_CWORD; in bash also COMP_LINE, COMP_POINT) and _NF_COMPLETE set to the shell: that is click's completion protocol between the script and nf, not a setting. Completing an input imports the app's module, as nf vars does, so a slow import makes ++ slow to complete.

Bash splits words at = and :, so ++env=pr and infra:web are several words to it; nf reads the word whole from the line, and gives each completion from where bash's word starts.