# Completion
pzsh provides intelligent auto-completion with optional ML-based predictions.
## Configuration
Enable completion in `~/.pzshrc`:
```toml
[completion]
enabled = true
# Optional: ML model for predictions
# model_path = "~/.pzsh/models/aprender-shell.onnx"
```
## Completion Sources
### Alias Completion
Completes configured aliases with expansion preview:
```
$ gs<TAB>
gs → git status
gp → git push
```
### Path Completion
Completes file and directory paths:
```
$ cd /usr/l<TAB>
/usr/lib
/usr/local
```
### Environment Variables
Completes environment variables:
```
$ echo $HO<TAB>
$HOME
$HOSTNAME
```
### History Completion
Completes from command history:
```
$ git com<TAB>
git commit -m 'fix typo'
git commit --amend
```
### Command Completion
Built-in completions for common commands:
- **git**: Subcommands, branches, remotes
- **docker**: Containers, images, commands
- **cargo**: Subcommands, packages
## Zsh Integration
pzsh generates native zsh completion functions:
```zsh
# Generated by pzsh compile
autoload -Uz compinit
compinit -C -d "${ZDOTDIR:-$HOME}/.zcompdump"
# Completion styling
zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
```
## ML-Based Predictions
When configured with an aprender-shell model:
```toml
[completion]
model_path = "~/.pzsh/models/aprender-shell.onnx"
```
The completion engine will:
1. Use traditional completions as fallback
2. Score suggestions using the ML model
3. Rank by predicted likelihood
4. Stay within 50ms budget
## Performance
- Completion lookup: O(1) via AHashMap
- Path scanning: Bounded to 100 entries
- ML inference: 50ms budget with fallback
- No blocking operations in critical path