Skip to content

Shell Completions

Spawn supports dynamic shell completions for Bash, Zsh, Fish, PowerShell, and Elvish. Completions are context-aware and include migration names, test names, and all command options.

  • Dynamic completions: Always reflects current migrations and tests in your project
  • Fuzzy-friendly: Works with shell fuzzy finders like fzf-tab

Add to your ~/.zshrc:

Terminal window
# Initialize zsh completion system (skip if using oh-my-zsh, prezto, etc.)
autoload -Uz compinit && compinit
source <(COMPLETE=zsh spawn)

If you’re using a zsh framework like oh-my-zsh or prezto, it already initializes compinit, so you only need the source line.

Add to your ~/.bashrc:

Terminal window
source <(COMPLETE=bash spawn)

Add to your Fish config (~/.config/fish/config.fish):

Terminal window
COMPLETE=fish spawn | source

Add to your PowerShell profile:

Terminal window
Invoke-Expression (& { $env:COMPLETE="powershell"; spawn })

Add to your Elvish config:

eval (COMPLETE=elvish spawn | slurp)

After setup, use Tab to complete:

Terminal window
# Complete subcommands
spawn migr<TAB>
# → spawn migration
# Complete migration names
spawn migration build <TAB>
# → 20260102030405-add-users
# → 20260103120000-create-posts
# Complete test names
spawn test run <TAB>
# → my-test
# → another-test

When working with many timestamped migrations, a fuzzy finder like fzf-tab can help you quickly filter by typing any part of the migration name.

With fzf-tab installed, pressing Tab opens an interactive fzf menu where you can type add-users to filter to 20260102030405-add-users, even though the completion value starts with a timestamp.