Skip to main content

Logo

shtab

Tests Coverage Quality PyPI conda-forge Downloads LICENCE

  • What: Automatically generate shell tab completion scripts for Python CLI apps

  • Why: Speed & correctness. Alternatives like argcomplete and pyzshcomplete are slow and have side-effects

  • How: shtab processes an argparse.ArgumentParser object to generate a tab completion script for your shell

Features

  • Outputs tab completion scripts for multiple shells

    • bash, zsh, fish, tcsh

  • Supports

  • <arguments>, --options and sub commands

  • Choices (--say={hello,goodbye}`)

  • Paths (--file={*.y*ml,*.toml}, --dir=*/)

  • Dynamic shell commands (--branch=$(git branch))


Installation

Choose one of:

  • pip install shtab, or

  • conda install -c conda-forge shtab

See operating system-specific instructions in the docs.

Usage

There are two ways of using shtab:

  • CLI Usage: shtab’s own CLI interface for external applications

    • may not require any code modifications whatsoever

    • end-users execute shtab your_cli_app.your_parser_object

  • Library Usage: as a library integrated into your CLI application

    • adds a couple of lines to your application

    • argument mode: end-users execute your_cli_app --print-completion {bash,zsh,tcsh,fish}

    • subparser mode: end-users execute your_cli_app completion {bash,zsh,tcsh,fish}

Examples

See the docs for usage examples.

FAQs

Not working? Check out frequently asked questions.

Alternatives

  • argcomplete

    • executes the underlying script every time <TAB> is pressed (slow and has side-effects)

  • pyzshcomplete

    • executes the underlying script every time <TAB> is pressed (slow and has side-effects)

    • only provides zsh completion

  • click

    • different framework completely replacing the builtin argparse

    • solves multiple problems (rather than POSIX-style “do one thing well”)

Contributions

Please do open issues & pull requests! Some ideas:

  • support powershell (#212)

  • support python -m prefix (#55)

See CONTRIBUTING.md for more guidance.

git-fame

Hits

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shtab-1.10.0.tar.gz (56.4 kB view details)

Uploaded Source

Built Distribution

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

shtab-1.10.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file shtab-1.10.0.tar.gz.

File metadata

  • Download URL: shtab-1.10.0.tar.gz
  • Upload date:
  • Size: 56.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for shtab-1.10.0.tar.gz
Algorithm Hash digest
SHA256 70ccd485d8b38d9458c42b4e911a3d29a685dbea4b9aa7ea2d03ebe1a6e6e94f
MD5 8cf525137c8cbf887f24f9d8b3ad68d7
BLAKE2b-256 bee2d174e5a176be1a4de07d125e8276bab2ce469a7d4a4919349e1a7d4f419d

See more details on using hashes here.

Provenance

The following attestation bundles were made for shtab-1.10.0.tar.gz:

Publisher: test.yml on tqdm/shtab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shtab-1.10.0-py3-none-any.whl.

File metadata

  • Download URL: shtab-1.10.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for shtab-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 927b63ccf29b12f0aa12a51860695026fcde2b6b2ae95fa7f4fbf0040bd14e90
MD5 3abe0a5a83172ccab39ec0c39ff5388d
BLAKE2b-256 c349c1a890168166db658a549f76d4732a40a38c6248127bc0eeb4d97b001f89

See more details on using hashes here.

Provenance

The following attestation bundles were made for shtab-1.10.0-py3-none-any.whl:

Publisher: test.yml on tqdm/shtab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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