# atmos completion

Use this command to generate completion scripts for `Bash`, `Zsh`, `Fish` and `PowerShell`.

_\[Video: atmos completion]_

## Usage

Execute the `completion` command like this:

```shell
atmos completion [bash|zsh|fish|powershell]
```

This command generates completion scripts for `Bash`, `Zsh`, `Fish` and `PowerShell`.

When the generated completion script is loaded into the shell, pressing the tab key twice displays the available commands and the help.

:::tip
Run `atmos completion --help` to see all the available options
:::

## Configuring Your Shell

To enable command completion, you need to configure your shell. The setup process depends on which shell you’re using (e.g., `zsh` or `bash`).

Select your shell below for detailed setup instructions.

### Bash

## Bash Completion Setup

To enable tab completion for Atmos in Bash, add the following to your `~/.bashrc` or `~/.bash_profile`:

```bash
# Enable Atmos CLI completion
source <(atmos completion bash)
```

After saving the file, apply the changes by running:

```zsh
source ~/.bashrc
```

Now, you can run any `atmos` command, and pressing `<Tab>` after typing `atmos` will show the available subcommands. The same applies to `--stack` arguments and commands requiring a component (e.g., `atmos terraform plan`).

### Zsh

## Zsh Completion Setup

To enable tab completion for Atmos in `Zsh`, add the following to your `~/.zshrc`:

```zsh
# Initialize Zsh completion system
autoload -Uz compinit && compinit

# Enable Atmos CLI completion
source <(atmos completion zsh)

# Improve completion behavior
zstyle ':completion:*' menu select      # Enable menu selection
zstyle ':completion:*' force-list always # Force vertical menu listing

# Ensure the Tab key triggers autocompletion
bindkey '\t' expand-or-complete
```

After saving the file, apply the changes by running:

```zsh
source ~/.zshrc
```

Now, you can run any `atmos` command, and pressing `<Tab>` after typing `atmos` will show the available subcommands. The same applies to `--stack` arguments and commands requiring a component (e.g., `atmos terraform plan`).

If completions do not work, try regenerating the completion cache:

```zsh
rm -f ~/.zcompdump && compinit
```

:::warning
The Atmos completion script statically completes [custom commands](/cli/configuration/commands) based on the Atmos configuration. If completions are generated without this configuration (e.g., outside a project directory), custom commands won’t be included. To ensure accuracy, generate or regenerate the script from the correct working directory. This only affects custom commands. Components, stacks, and built-in commands remain fully dynamic.
:::

### Examples

```shell
atmos completion bash
atmos completion zsh
atmos completion fish
atmos completion powershell
```

You can generate and load the shell completion script for `Bash` by executing the following commands:

```shell
atmos completion bash > /tmp/completion
source /tmp/completion
```

or

```shell
source <(atmos completion bash)
```

## Arguments

- **`shell_name` (required)**
  Shell name. Valid values are 
  `bash`
  , 
  `zsh`
  , 
  `fish`
   and 
  `powershell`
  .

:::info
Refer to [Command-line completion](https://en.wikipedia.org/wiki/Command-line_completion) for more details
:::
