> ## 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:

<AccordionGroup>
  <Accordion title="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>

  <Accordion title="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>

  <Accordion title="Profile names">
    `cpln workload get --profile <Tab>` lists your configured profiles.

    ```bash theme={null}
    cpln workload get --profile <Tab>
    # default  staging  production  ...
    ```
  </Accordion>

  <Accordion title="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>

  <Accordion title="File paths">
    `cpln apply --file <Tab>` triggers native file path completion.

    ```bash theme={null}
    cpln apply --file <Tab>
    # workload.yaml  gvc.yaml  secrets/  ...
    ```
  </Accordion>
</AccordionGroup>

## 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:

<Tabs>
  <Tab title="Bash">
    ```bash theme={null}
    cpln misc install-completion --batch --shell bash
    ```
  </Tab>

  <Tab title="Zsh">
    ```bash theme={null}
    cpln misc install-completion --batch --shell zsh
    ```
  </Tab>

  <Tab title="Fish">
    ```bash theme={null}
    cpln misc install-completion --batch --shell fish
    ```
  </Tab>
</Tabs>

<Tip>
  After installing completion, restart your terminal or source your shell profile for the changes to take effect.
</Tip>

<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.
</Note>

## Uninstall completion

To remove shell completion from your profile:

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

## Troubleshooting

<AccordionGroup>
  <Accordion title="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:

           <Tabs>
             <Tab title="Bash">
               ```bash theme={null}
               source ~/.bashrc
               ```
             </Tab>

             <Tab title="Zsh">
               ```bash theme={null}
               source ~/.zshrc
               ```
             </Tab>

             <Tab title="Fish">
               Fish loads completions automatically. Try restarting your terminal.
             </Tab>
           </Tabs>

    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>

  <Accordion title="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>

  <Accordion title="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
    ```
  </Accordion>
</AccordionGroup>

## Command reference

<CardGroup cols={2}>
  <Card title="cpln misc" href="/cli-reference/commands/misc" icon="terminal">
    Full command reference for install-completion and uninstall-completion
  </Card>
</CardGroup>
