shtab
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, powershell
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
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,powershell}
subparser mode: end-users execute your_cli_app completion {bash,zsh,tcsh,fish,powershell}
Examples
FAQs
Not working? Check out frequently asked questions.
Alternatives
All these execute the underlying script every time <TAB> is pressed (slow and have side-effects):
pyzshcomplete (only provides zsh completion)
click (don’t want to migrate away from click? Use shtab’s one-liner click integration in the CLI or in a library)
Contributions
Please do open issues & pull requests! Some ideas:
support python -m prefix (#55)
See CONTRIBUTING.md for more guidance.
Metadata
Release files for shtab 1.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shtab-1.13.0.tar.gz | 67.7 kB | With provenance | Details for shtab-1.13.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shtab-1.13.0-py3-none-any.whl | Python 3 | none | any | Details for shtab-1.13.0-py3-none-any.whl |
Total release size: 90.5 kB
Release files / shtab-1.13.0.tar.gz
| Download URL | shtab-1.13.0.tar.gz |
|---|---|
| Size | 67.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a5be9d7ab2b4549e9a38252abcd5ecf5ec6813ecd80c6b06fa851bff55a5085
|
|
BLAKE2b-256 checksum How to use checksums |
ffdde58588cf2d02266d504f4399979740b8b2b61fbd7719a89578afaa6558a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.15.0
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / shtab-1.13.0-py3-none-any.whl
| Download URL | shtab-1.13.0-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdf7543fc1888dd131320917f3ba9643d8f1a77d406114a09d5a31f76274c7d9
|
|
BLAKE2b-256 checksum How to use checksums |
6aa62179498fd9d8a25ce1ae049f434442aa4d7bae2361bbac62eeb19107be8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.15.0
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for shtab 1.13.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for shtab-1.13.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.