﻿# Install autocomplete

Install a shell auto-complete script into your shell profile, if they aren't already there. Supports pwsh, zsh, bash, and PowerShell.

## install-autocomplete options

```text
Install a shell auto-complete script into your shell profile, if they aren't already there. Supports pwsh, zsh, bash & PowerShell.

Usage: octo install-autocomplete [<options>]

Where [<options>] is any of:

Install AutoComplete:

      --shell=VALUE          The type of shell to install auto-complete
                             scripts for. This will alter your shell
                             configuration files. Supported shells are Bash,
                             PowerShell, Pwsh and Zsh.
      --dryRun               [Optional] Dry run will output the proposed
                             changes to console, instead of writing to disk.

Common options:

      --help                 [Optional] Print help for a command.
      --helpOutputFormat=VALUE
                             [Optional] Output format for help, valid options
                             are Default or Json
```

## Tab completion for commands and options {#OctopusCLI-TabCompletion}

Tab completion is available for the following shell environments: `powershell`, `pwsh` (PowerShell Core), `bash` & `zsh`. This feature requires that `octo` or `Octo` is available from your $PATH, which is the default state if installed via a package manager or Chocolatey. If you've manually installed the CLI, please ensure your $PATH is also updated if you wish to use this feature. This is an optional feature that requires additional [installation steps](#OctopusCLI-TabCompletionInstallation) on a per-user basis, since this feature relies on built-in shell auto-completion facilities.

### Additional installation steps for tab completion. {#OctopusCLI-TabCompletionInstallation}

1. Check that `octo` is available on your path:

    ```bash
    which octo
    ```

    This should return a valid location on your path like `/usr/bin/octo`.

2. Install tab completion scripts into your profile, choosing from `powershell`, `pwsh`, `bash` or `zsh`:

```bash
octo install-autocomplete --shell zsh
```

:::div{.hint}
**Tips:**

- If you're using PowerShell on Windows use `powershell`. If you're using PowerShell Core on Windows, Mac or Linux, use `pwsh`.
- You can review changes to your profile without writing to disk by using the `--dryRun` option:

```powershell
octo install-autocomplete --shell powershell --dryRun
```

:::

3. Either restart your shell environment or 'dot source' your profile:

    <details data-group="restart-shell-environment">
    <summary>Bash</summary>

    ```bash
    . ~/.bashrc
    ```

    </details>
    <details data-group="restart-shell-environment">
    <summary>Zsh</summary>

    ```bash
    . ~/.zshrc
    ```

    </details>
    <details data-group="restart-shell-environment">
    <summary>PowerShell</summary>

    ```powershell
    . $PROFILE
    ```

    </details>

4. You can now discover sub-commands by typing `octo [search-term]` and hitting the [tab] key. If you don't provide a search term, the full list of available sub-commands will be shown.

![animation showing the tab completion feature in Zsh to list all environments in the default space](/docs/shared-content/images/autocomplete.gif)
