# Shell completion

`kanject completion <SHELL>` writes a completion script for the registered command tree, including loaded providers, nested subcommands, and visible option aliases. It does not edit your shell profile.

## Bash

```bash
# Enable for this session
source <(kanject completion bash)

# Or save it, then source it from ~/.bashrc
kanject completion bash > ~/.kanject-completion.bash
source ~/.kanject-completion.bash
```

## Zsh

```bash
autoload -Uz compinit
compinit
source <(kanject completion zsh)

# For new sessions, save and source after completion initialization in ~/.zshrc
kanject completion zsh > ~/.kanject-completion.zsh
source ~/.kanject-completion.zsh
```

Initialize `compinit` before sourcing the script; most Zsh frameworks already do this.

## PowerShell 7+

```powershell
kanject completion powershell | Set-Content "$HOME/kanject-completion.ps1"
. "$HOME/kanject-completion.ps1"

# Add the dot-source line above to $PROFILE for new sessions
```

`pwsh` is an alias for the `powershell` shell selector. Unsupported shells fail with `KANCLI663` and a supported-shell hint.

## What completion knows

Try `kanject aws de<Tab>` or `kanject aws deploy --bu<Tab>`. Completion follows the command path and understands option values, including quoted paths. Required values use the shell’s normal file-completion fallback. Stage names, entry IDs, AWS resource names, and template aliases are not dynamically queried or suggested.

Tab completion runs no CLI process and makes no network call. Saved scripts reflect the command tree at generation time: regenerate them after updating Kanject or adding/removing a provider.

Related: [Command Map](https://www.kanject.com/docs/cli-commands/) · [Installation](https://www.kanject.com/docs/installation/).

---
_Source: https://www.kanject.com/docs/cli-completion/ · Kanject Docs_
