Skip to content

Shell completions for neo

The neo CLI can print a completion script for your shell:

Terminal window
neo completion <shell>

<shell> is one of bash, zsh, fish, elvish or powershell. The script goes to stdout — it is never installed as a side effect, so you choose where it lands.

The scripts are generated from the CLI’s own command tree, so they cover every subcommand and flag the binary you are running actually has. They cannot drift from --help, and a completion script from an older neo is simply an older command set — regenerate after upgrading.

Needs the bash-completion package.

Terminal window
mkdir -p ~/.local/share/bash-completion/completions
neo completion bash > ~/.local/share/bash-completion/completions/neo

Open a new shell. For a system-wide install, write to /usr/share/bash-completion/completions/neo instead.

The file must be named _neo and live in a directory on $fpath:

Terminal window
mkdir -p ~/.local/share/zsh/site-functions
neo completion zsh > ~/.local/share/zsh/site-functions/_neo

If that directory is not already on $fpath, add this to ~/.zshrc before compinit runs:

Terminal window
fpath=(~/.local/share/zsh/site-functions $fpath)
autoload -Uz compinit && compinit

zsh caches completion definitions; run rm -f ~/.zcompdump && compinit after replacing the file.

Terminal window
mkdir -p ~/.config/fish/completions
neo completion fish > ~/.config/fish/completions/neo.fish

fish picks it up in new shells with no further configuration.

Terminal window
mkdir -p ~/.config/elvish/lib
neo completion elvish > ~/.config/elvish/lib/neo.elv

Then add use neo to ~/.config/elvish/rc.elv.

Append the script to your profile:

Terminal window
neo completion powershell | Out-String | Invoke-Expression

To make it permanent, add that line to the file $PROFILE points at (New-Item -Type File -Force $PROFILE creates it if it does not exist).

Completions are a snapshot of the command tree at the moment you generated them. Regenerate whenever you upgrade neo:

Terminal window
neo completion zsh > ~/.local/share/zsh/site-functions/_neo

Re-running the installer does this for bash, zsh and fish automatically, so an upgrade through get.neosource.dev needs no manual step.