Automatically generate shell completions for Python tools installed via uv and pipx.
Currently, bash, zsh, and fish on Linux are supported. Also, only Python
tools that use the click or argcomplete libraries are supported,
besides some select commands:
uvuvx
uv tool install pycompgen
# Or if you prefer pipx:
pipx install pycompgenRun pycompgen to generate completions for all installed tools:
pycompgenThe tool will:
- Detect Python packages installed via
uv toolandpipxas well as some select commands - Analyze which ones support shell completions
- Generate completion files in
~/.cache/pycompgen/ - Create a source script to load all completions
Add the source script to your shell config:
# For bash: - add to ~/.bashrc:
source <(pycompgen --source) ; (pycompgen &)
# For zsh: - add to ~/.zshrc:
source <(pycompgen --shell zsh --source) ; (pycompgen --shell zsh &)This will load the generated shell completions and generate new completions for the next time.
The fish shell will automatically read the completions generated by
pycompgen in .cache/fish/generated_completions.
--cache-dir PATH: Override the default cache directory--force: Force regeneration of all completions--shell: Target shell - bash, zsh, or fish (default: ${PYCOMPGEN_SHELL:-bash})--verbose: Enable detailed output--source: Only write the source file contents to stdout and exit--cooldown-time: Minimum amount of seconds between regenerations
Install development dependencies:
uv sync --group dev
uv run pre-commit installRun tests:
uv run pytestRun linting and formatting:
uv run ruff check src tests
uv run ruff format src tests
uv run mypy srcMIT