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

# pixi completion

Generate shell completion scripts.

## Usage

```bash theme={null}
pixi completion --shell <SHELL>
```

## Description

The `pixi completion` command generates shell completion scripts that provide tab-completion for pixi commands, options, and arguments. The completion script includes smart completions for:

* Task names when using `pixi run`
* Environment names for `--environment` flag
* Package names for various commands

## Options

<ParamField path="--shell" type="enum" required>
  The shell to generate completions for.

  **Supported shells:**

  * `bash` - Bourne Again SHell
  * `zsh` - Z Shell
  * `fish` - Friendly Interactive SHell
  * `powershell` - PowerShell
  * `elvish` - Elvish shell
  * `nushell` - Nushell

  ```bash theme={null}
  pixi completion --shell bash
  pixi completion --shell zsh
  pixi completion --shell fish
  ```
</ParamField>

## Installation

### Bash

Add to your `~/.bashrc`:

```bash theme={null}
eval "$(pixi completion --shell bash)"
```

Or install system-wide:

```bash theme={null}
pixi completion --shell bash | sudo tee /etc/bash_completion.d/pixi
```

### Zsh

Add to your `~/.zshrc`:

```bash theme={null}
eval "$(pixi completion --shell zsh)"
```

Or install to a directory in your `$fpath`:

```bash theme={null}
pixi completion --shell zsh > ~/.zsh/completions/_pixi
```

Make sure the completion directory is in your `fpath` before compinit:

```bash theme={null}
# In ~/.zshrc before compinit
fpath=(~/.zsh/completions $fpath)
```

### Fish

Install to Fish completions directory:

```bash theme={null}
pixi completion --shell fish > ~/.config/fish/completions/pixi.fish
```

### PowerShell

Add to your PowerShell profile:

```powershell theme={null}
pixi completion --shell powershell | Out-String | Invoke-Expression
```

To find your profile location:

```powershell theme={null}
$PROFILE
```

### Nushell

Add to your Nushell config:

```bash theme={null}
pixi completion --shell nushell | save -f ~/.config/nushell/completions/pixi.nu
```

Then source it in your `config.nu`:

```nushell theme={null}
source ~/.config/nushell/completions/pixi.nu
```

### Elvish

Add to your `~/.elvish/rc.elv`:

```elvish theme={null}
eval (pixi completion --shell elvish | slurp)
```

## Features

### Command Completion

Tab-complete pixi commands:

```bash theme={null}
pixi <TAB>
# Shows: add, auth, build, clean, completion, config, exec, ...
```

### Task Completion

Tab-complete task names when using `pixi run`:

```bash theme={null}
pixi run <TAB>
# Shows available tasks: test, lint, build, format, ...
```

### Environment Completion

Tab-complete environment names:

```bash theme={null}
pixi run --environment <TAB>
# Shows: default, prod, test, dev, ...
```

### Option Completion

Tab-complete command options:

```bash theme={null}
pixi add --<TAB>
# Shows: --help, --manifest-path, --host, --build, --pypi, ...
```

## Examples

### Generate bash completions

```bash theme={null}
pixi completion --shell bash
```

### Install bash completions

```bash theme={null}
# For current user
pixi completion --shell bash >> ~/.bashrc
source ~/.bashrc

# System-wide
pixi completion --shell bash | sudo tee /etc/bash_completion.d/pixi
```

### Install zsh completions

```bash theme={null}
mkdir -p ~/.zsh/completions
pixi completion --shell zsh > ~/.zsh/completions/_pixi

# Add to ~/.zshrc if not already present:
echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
```

### Install fish completions

```bash theme={null}
mkdir -p ~/.config/fish/completions
pixi completion --shell fish > ~/.config/fish/completions/pixi.fish
```

## Troubleshooting

<Accordion title="Completions not working">
  1. Make sure you've sourced your shell config after installation:
     ```bash theme={null}
     source ~/.bashrc  # or ~/.zshrc, etc.
     ```

  2. For zsh, ensure the completion directory is in your `$fpath` before compinit

  3. Check that the completion script was generated correctly:
     ```bash theme={null}
     pixi completion --shell bash | head
     ```
</Accordion>

<Accordion title="Task completion not showing tasks">
  Task completion requires:

  * Being inside a pixi workspace
  * Having a valid `pixi.toml` with tasks defined
  * The workspace being initialized (`pixi install`)

  Try:

  ```bash theme={null}
  cd /path/to/pixi-workspace
  pixi run <TAB>
  ```
</Accordion>

<Accordion title="Zsh: command not found: compdef">
  Make sure you have compinit loaded in your `.zshrc`:

  ```bash theme={null}
  autoload -Uz compinit && compinit
  ```
</Accordion>

## Implementation Details

The completion script provides intelligent context-aware completions:

* **Dynamic task completion**: Reads tasks from `pixi.toml` in real-time
* **Environment completion**: Lists available environments from the workspace
* **Platform completion**: Suggests valid platform identifiers
* **Path completion**: Automatically completes file paths where appropriate

## Related Commands

* [`pixi run`](/commands/run) - Benefits from task name completion
* [`pixi task`](/commands/task) - Task completion shows these tasks
