Generate shell completions automatically
Project description
pycompgen
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
Installation
uv tool install pycompgen
# Or if you prefer pipx:
pipx install pycompgen
Usage
Run pycompgen to generate completions for all installed tools:
pycompgen
The 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 &)
# For fish: - add to ~/.config/fish/config.fish:
pycompgen --shell fish &; disown
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.
Options
--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
Development
Install development dependencies:
uv sync --group dev
uv run pre-commit install
Run tests:
uv run pytest
Run linting and formatting:
uv run ruff check src tests
uv run ruff format src tests
uv run mypy src
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pycompgen-0.3.0.tar.gz.
File metadata
- Download URL: pycompgen-0.3.0.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7a0d85d7ad038fae4094c9343496ed351ddf2014e8b5c2312bf8bbae2ae7bde
|
|
| MD5 |
e9e1f3eb4efdd777037027aa953bf476
|
|
| BLAKE2b-256 |
8239402e80292de3cc4d665cd1d52a34ff720faada368cec2aac4aff65423073
|