Skip to main content

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:

  • uv
  • uvx

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:

  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:

# 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 --source | source ; pycompgen --shell fish &

This will load the generated shell completions and generate new completions for the next time.

Options

  • --cache-dir PATH: Override the default cache directory
  • --force: Force regeneration of all completions
  • --shell: Target shell - bash, zsh, or fish (default: ${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

pycompgen-0.2.0.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycompgen-0.2.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file pycompgen-0.2.0.tar.gz.

File metadata

  • Download URL: pycompgen-0.2.0.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for pycompgen-0.2.0.tar.gz
Algorithm Hash digest
SHA256 da0d0a63d2616b547e0ea25d32a4aa9ed7ac3cf83a24212e60e179ba5714f262
MD5 16f66a9b76709e090b0a966aa1da4a10
BLAKE2b-256 4b14fec4cb66c555324198c075d86e12ee1f89a7d85ba2b4965eaa495d31d073

See more details on using hashes here.

File details

Details for the file pycompgen-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pycompgen-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for pycompgen-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd0477206bab2d585c510842eae9ecf64333d20a78ba8b98a46f314cc709f0e1
MD5 ddc725b513152cf806aa308629e5bb1b
BLAKE2b-256 d19766912103e06eb3638bba08b693e030c34ac227ca0cf2743900a39ebd8659

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page