Skip to content

completion

Generate shell completion scripts for NDCLI. Tab completion helps you discover commands, flags, and arguments quickly.

Supported Shells

ShellCommand
Bashndcli completion bash
Zshndcli completion zsh
Fishndcli completion fish
PowerShellndcli completion powershell

Bash

Generate the autocompletion script for Bash.

Terminal window
ndcli completion bash

Installation

Add to your ~/.bashrc:

Terminal window
source <(ndcli completion bash)

Or save to the completions directory:

Terminal window
ndcli completion bash > /etc/bash_completion.d/ndcli

Notes

  • Requires bash-completion package
  • Changes take effect in new shell sessions
  • Run source ~/.bashrc to apply immediately

Zsh

Generate the autocompletion script for Zsh.

Terminal window
ndcli completion zsh

Installation

Add to your ~/.zshrc:

Terminal window
source <(ndcli completion zsh)

Or save to your completions directory:

Terminal window
ndcli completion zsh > "${fpath[1]}/_ndcli"

If Completions Don’t Work

Ensure compinit is initialized. Add to ~/.zshrc before sourcing completions:

Terminal window
autoload -Uz compinit && compinit

Fish

Generate the autocompletion script for Fish shell.

Terminal window
ndcli completion fish

Installation

Add to your ~/.config/fish/config.fish:

ndcli completion fish | source

Or save to completions directory:

ndcli completion fish > ~/.config/fish/completions/ndcli.fish

PowerShell

Generate the autocompletion script for PowerShell.

Terminal window
ndcli completion powershell

Installation

Add to your PowerShell profile ($PROFILE):

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

To load for every session, add the above line to your profile:

Terminal window
notepad $PROFILE

Completion Features

Once installed, tab completion provides:

Command Discovery

Terminal window
ndcli <TAB>

Subcommand Discovery

Terminal window
ndcli device <TAB>

Flag Discovery

Terminal window
ndcli device list --<TAB>

Flag Values

Terminal window
ndcli device list --status <TAB>
ndcli device list --format <TAB>

Troubleshooting

Completions Not Working

  1. Restart your shell - New completion scripts need a fresh shell
  2. Check if script is loaded - Verify the source command is in your rc file
  3. Check bash-completion - Ensure bash-completion package is installed

Slow Completions

If completions are slow, they may be fetching data from the API. Consider:

  • Checking network connectivity
  • Ensuring you’re authenticated (ndcli auth show)

Updating Completions

Regenerate completions after NDCLI updates:

Terminal window
ndcli completion bash > ~/.local/share/bash-completion/completions/ndcli
ndcli completion zsh > "${fpath[1]}/_ndcli"
ndcli completion fish > ~/.config/fish/completions/ndcli.fish