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

# Completion

# completion

> Generate shell completion scripts for bash, zsh, and fish

Generate shell completion scripts to enable tab completion for App Store Connect CLI commands.

## Quick Start

```bash theme={null} theme={null}
# Bash
asc completion --shell bash >> ~/.bashrc

# Zsh
asc completion --shell zsh >> ~/.zshrc

# Fish
asc completion --shell fish > ~/.config/fish/completions/asc.fish
```

## Usage

```bash theme={null} theme={null}
asc completion --shell <bash|zsh|fish>
```

**Flags:**

* `--shell` - Shell type: `bash`, `zsh`, or `fish` (required)

## Supported Shells

### Bash

Generate and load bash completion:

```bash theme={null} theme={null}
# Generate completion script
asc completion --shell bash > /tmp/asc-completion.bash

# Add to .bashrc
echo 'source /tmp/asc-completion.bash' >> ~/.bashrc

# Reload shell
source ~/.bashrc
```

Or append directly:

```bash theme={null} theme={null}
asc completion --shell bash >> ~/.bashrc
source ~/.bashrc
```

### Zsh

Generate and load zsh completion:

```bash theme={null} theme={null}
# Generate completion script
asc completion --shell zsh > /tmp/asc-completion.zsh

# Add to .zshrc
echo 'source /tmp/asc-completion.zsh' >> ~/.zshrc

# Reload shell
source ~/.zshrc
```

Or append directly:

```bash theme={null} theme={null}
asc completion --shell zsh >> ~/.zshrc
source ~/.zshrc
```

### Fish

Generate and install fish completion:

```bash theme={null} theme={null}
# Create completions directory if it doesn't exist
mkdir -p ~/.config/fish/completions

# Generate completion script
asc completion --shell fish > ~/.config/fish/completions/asc.fish

# Reload completions (or restart fish)
fish_update_completions
```

## How It Works

The completion script provides tab completion for:

* Top-level commands (e.g., `builds`, `testflight`, `metadata`)
* Common flags (basic support)

**Example:**

```bash theme={null} theme={null}
$ asc <TAB>
auth          builds        completion    devices       
migrate       metadata      notify        profiles      
submit        testflight    users         webhooks      
workflow      xcode-cloud
```

## Manual Installation

### Bash (Linux)

```bash theme={null} theme={null}
# System-wide (requires sudo)
sudo asc completion --shell bash > /etc/bash_completion.d/asc

# User-level
mkdir -p ~/.local/share/bash-completion/completions
asc completion --shell bash > ~/.local/share/bash-completion/completions/asc
```

### Bash (macOS with Homebrew)

```bash theme={null} theme={null}
# Install bash-completion if not already installed
brew install bash-completion@2

# Add to Homebrew's completion directory
asc completion --shell bash > $(brew --prefix)/etc/bash_completion.d/asc
```

### Zsh (with Oh My Zsh)

```bash theme={null} theme={null}
# Create custom completion directory
mkdir -p ~/.oh-my-zsh/custom/plugins/asc

# Generate completion
asc completion --shell zsh > ~/.oh-my-zsh/custom/plugins/asc/_asc

# Add to .zshrc plugins
# plugins=(... asc)
```

### Zsh (macOS with Homebrew)

```bash theme={null} theme={null}
# Add to Homebrew's completion directory
asc completion --shell zsh > $(brew --prefix)/share/zsh/site-functions/_asc

# Rebuild completion cache
rm -f ~/.zcompdump
compinit
```

## Verification

Test that completion is working:

```bash theme={null} theme={null}
# Type the command and press TAB
asc <TAB>

# Should show available commands
```

If completion doesn't work:

1. Verify the script was added to the correct location
2. Reload your shell configuration
3. Check for syntax errors in the completion script

## Troubleshooting

### Bash: Command not found

Ensure bash-completion is installed:

```bash theme={null} theme={null}
# Ubuntu/Debian
sudo apt-get install bash-completion

# macOS with Homebrew
brew install bash-completion@2
```

### Zsh: Completion not loading

Ensure completion is enabled in `.zshrc`:

```bash theme={null} theme={null}
# Add to .zshrc if missing
autoload -Uz compinit
compinit
```

### Fish: Permission denied

Ensure the completions directory exists and is writable:

```bash theme={null} theme={null}
mkdir -p ~/.config/fish/completions
chmod 755 ~/.config/fish/completions
```

## Advanced Configuration

### Custom Completion Location

Save completion to a custom location:

```bash theme={null} theme={null}
# Create custom directory
mkdir -p ~/my-completions

# Generate completion
asc completion --shell bash > ~/my-completions/asc-completion.bash

# Add to .bashrc
echo 'source ~/my-completions/asc-completion.bash' >> ~/.bashrc
```

### Conditional Loading

Load completion only when `asc` is available:

```bash theme={null} theme={null}
# Add to .bashrc or .zshrc
if command -v asc &> /dev/null; then
  source ~/my-completions/asc-completion.bash
fi
```

## CI/CD Integration

Generate completion in Docker containers:

```dockerfile theme={null} theme={null}
FROM ubuntu:22.04

RUN apt-get update && apt-get install -y bash-completion

COPY asc /usr/local/bin/asc
RUN asc completion --shell bash > /etc/bash_completion.d/asc

CMD ["/bin/bash"]
```

## Updates

Regenerate completion after upgrading the CLI:

```bash theme={null} theme={null}
# Bash
asc completion --shell bash > /tmp/asc-completion.bash
source /tmp/asc-completion.bash

# Zsh
asc completion --shell zsh > /tmp/asc-completion.zsh
source /tmp/asc-completion.zsh

# Fish
asc completion --shell fish > ~/.config/fish/completions/asc.fish
fish_update_completions
```
