https://github.com/adrianvollmer/pycompgen
Automatically generate shell completions for Python tools installed via uv and pipx.
https://github.com/adrianvollmer/pycompgen
bash completion pipx python tabcompletion uv zsh
Last synced: 10 days ago
JSON representation
Automatically generate shell completions for Python tools installed via uv and pipx.
- Host: GitHub
- URL: https://github.com/adrianvollmer/pycompgen
- Owner: AdrianVollmer
- License: mit
- Created: 2025-07-05T16:22:47.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-10-19T15:00:37.000Z (6 months ago)
- Last Synced: 2026-01-24T13:06:01.159Z (3 months ago)
- Topics: bash, completion, pipx, python, tabcompletion, uv, zsh
- Language: Python
- Homepage:
- Size: 165 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
- `uv`
- `uvx`
## Installation
``` bash
uv tool install pycompgen
# Or if you prefer pipx:
pipx install pycompgen
```
## Usage
Run pycompgen to generate completions for all installed tools:
``` bash
pycompgen
```
The tool will:
1. Detect Python packages installed via `uv tool` and `pipx` as well as
some select commands
2. Analyze which ones support shell completions
3. Generate completion files in `~/.cache/pycompgen/`
4. Create a source script to load all completions
Add the source script to your shell config:
``` bash
# 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`.
### 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:
``` bash
uv sync --group dev
uv run pre-commit install
```
Run tests:
``` bash
uv run pytest
```
Run linting and formatting:
``` bash
uv run ruff check src tests
uv run ruff format src tests
uv run mypy src
```
## License
MIT