Skip to main content

Shell completion

Generate a completion script with pyrefly completion --shell <shell>. Supported shells are bash, zsh, fish, powershell, and elvish. The script is written to standard output.

Bash

Add this to ~/.bashrc:

source <(pyrefly completion --shell bash)

Zsh

Add this to ~/.zshrc after initializing completion with compinit:

autoload -Uz compinit
compinit
source <(pyrefly completion --shell zsh)

Fish

Save the script in the completions directory:

mkdir -p ~/.config/fish/completions
pyrefly completion --shell fish > ~/.config/fish/completions/pyrefly.fish

PowerShell

Add this to your profile ($PROFILE):

pyrefly completion --shell powershell | Out-String | Invoke-Expression

Elvish

Save the script and load it from ~/.config/elvish/rc.elv:

mkdir -p ~/.config/elvish/lib
pyrefly completion --shell elvish > ~/.config/elvish/lib/pyrefly.elv
use pyrefly

Restart your shell after setup. Regenerate saved completion files after upgrading Pyrefly to include any new commands and options.