> ## Documentation Index
> Fetch the complete documentation index at: https://docs.controlplane.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Shell Completion

> Enable tab completion for the Control Plane CLI in your terminal.

Shell completion enables tab-based autocompletion for `cpln` commands, subcommands, and flags in your terminal. Press `Tab` to autocomplete commands, discover available subcommands, and fill in flag names.

## Supported shells

| Shell | Supported |
| - | - |
| Bash | Yes |
| Zsh | Yes |
| Fish | Yes |

## What gets completed

Shell completion supports the following:

> [accordion] Commands and subcommands
>
> `cpln workload <Tab>` shows available subcommands like `get`, `create`, `delete`.
>
> ```bash theme={null}
> cpln workload <Tab>
> # get  create  delete  update  patch  ...
> ```

> [accordion] Flags and options
>
> `cpln workload get --<Tab>` shows available flags like `--org`, `--gvc`, `--output`.
>
> ```bash theme={null}
> cpln workload get --<Tab>
> # --org  --gvc  --output  --max  --verbose  ...
> ```

> [accordion] Profile names
>
> `cpln workload get --profile <Tab>` lists your configured profiles.
>
> ```bash theme={null}
> cpln workload get --profile <Tab>
> # default  staging  production  ...
> ```

> [accordion] API endpoint
>
> `cpln workload get --endpoint <Tab>` suggests the API endpoint URL.
>
> ```bash theme={null}
> cpln workload get --endpoint <Tab>
> # https://api.cpln.io
> ```

> [accordion] File paths
>
> `cpln apply --file <Tab>` triggers native file path completion.
>
> ```bash theme={null}
> cpln apply --file <Tab>
> # workload.yaml  gvc.yaml  secrets/  ...
> ```

## Install completion

Run the following command to install shell completion:

```bash theme={null}
cpln misc install-completion
```

By default, this runs in interactive mode and prompts you to select your shell. After installation, **restart your terminal** for the changes to take effect.

### Options

| Flag | Alias | Description |
| - | - | - |
| `--shell` | | Specify the shell to install completion for (`bash`, `zsh`, or `fish`) |
| `--batch` | `-b` | Run in non-interactive (batch) mode, skipping prompts |

### Non-interactive installation

Use `--batch` and `--shell` together to skip the interactive prompts:

> [tab] Bash
>
> ```bash theme={null}
> cpln misc install-completion --batch --shell bash
> ```

> [tab] Zsh
>
> ```bash theme={null}
> cpln misc install-completion --batch --shell zsh
> ```

> [tab] Fish
>
> ```bash theme={null}
> cpln misc install-completion --batch --shell fish
> ```

> [!TIP]
>
> After installing completion, restart your terminal or source your shell profile for the changes to take effect.

> [!NOTE]
>
> When installing completion for Zsh, `compinit` is automatically configured in `~/.zshrc` if it is not already present. This is required for Zsh's completion system to work and is left in place during uninstallation since other tools may depend on it.

## Uninstall completion

To remove shell completion from your profile:

```bash theme={null}
cpln misc uninstall-completion
```

## Troubleshooting

> [accordion] Completion not working after installation
>
> **Problem**: Tab completion doesn't work after running `install-completion`.
>
> **Solutions**:
>
> 1. Restart your terminal or source your shell profile:
>
>    > [tab] Bash
>    >
>    > ```bash theme={null}
>    > source ~/.bashrc
>    > ```
>
>    > [tab] Zsh
>    >
>    > ```bash theme={null}
>    > source ~/.zshrc
>    > ```
>
>    > [tab] Fish
>    >
>    > Fish loads completions automatically. Try restarting your terminal.
>
> 2. Verify the CLI is on your PATH:
>    ```bash theme={null}
>    which cpln
>    ```
>
> 3. Reinstall completion:
>    ```bash theme={null}
>    cpln misc uninstall-completion
>    cpln misc install-completion
>    ```

> [accordion] Installation fails on macOS (Apple Silicon)
>
> **Problem**: Completion installation fails on a Mac with Apple Silicon.
>
> **Solution**: Install Rosetta, then retry:
>
> ```bash theme={null}
> softwareupdate --install-rosetta
> cpln misc install-completion
> ```

> [accordion] Completion not available for a new command
>
> **Problem**: Tab completion doesn't include recently added commands or flags.
>
> **Solution**: Reinstall completion after updating the CLI:
>
> ```bash theme={null}
> cpln misc uninstall-completion
> cpln misc install-completion
> ```

## Command reference

> [card] [cpln misc](https://docs.controlplane.com/cli-reference/commands/misc.md)
>
> Full command reference for install-completion and uninstall-completion
