Automagic shell tab completion for Python CLI applications
Project description
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
bash
zsh
tcsh
Supports
Supports arguments, options and subparsers
Supports choices (e.g. --say={hello,goodbye})
Supports file and directory path completion
Supports custom path completion (e.g. --file={*.txt})
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}
subparser mode: end-users execute your_cli_app completion {bash,zsh,tcsh}
Examples
FAQs
Not working? Check out frequently asked questions.
Alternatives
-
executes the underlying script every time <TAB> is pressed (slow and has side-effects)
-
executes the underlying script every time <TAB> is pressed (slow and has side-effects)
only provides zsh completion
-
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 fish (#174)
support powershell
See CONTRIBUTING.md for more guidance.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shtab-1.8.0.tar.gz.
File metadata
- Download URL: shtab-1.8.0.tar.gz
- Upload date:
- Size: 46.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75f16d42178882b7f7126a0c2cb3c848daed2f4f5a276dd1ded75921cc4d073a
|
|
| MD5 |
c6d611ee1ebe0e19ebb16a75749cd658
|
|
| BLAKE2b-256 |
b07a7f131b6082d8b592c32e4312d0a6da3d0b28b8f0d305ddd93e49c9d89929
|
Provenance
The following attestation bundles were made for shtab-1.8.0.tar.gz:
Publisher:
test.yml on iterative/shtab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shtab-1.8.0.tar.gz -
Subject digest:
75f16d42178882b7f7126a0c2cb3c848daed2f4f5a276dd1ded75921cc4d073a - Sigstore transparency entry: 707444829
- Sigstore integration time:
-
Permalink:
iterative/shtab@ca1d284f7fc3f8e0cd6ce41cafb0221cde5f15da -
Branch / Tag:
refs/tags/v1.8.0 - Owner: https://github.com/iterative
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@ca1d284f7fc3f8e0cd6ce41cafb0221cde5f15da -
Trigger Event:
push
-
Statement type:
File details
Details for the file shtab-1.8.0-py3-none-any.whl.
File metadata
- Download URL: shtab-1.8.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0922a82174b4007e06ac0bac4f79abd826c5cca88e201bfd927f889803c571d
|
|
| MD5 |
9d369a28ef819ea500589e01794b2399
|
|
| BLAKE2b-256 |
8ee1202a31727b0d096a04380f78e809074d7a1d0a22d9d5a39fea1d2353fd02
|
Provenance
The following attestation bundles were made for shtab-1.8.0-py3-none-any.whl:
Publisher:
test.yml on iterative/shtab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shtab-1.8.0-py3-none-any.whl -
Subject digest:
f0922a82174b4007e06ac0bac4f79abd826c5cca88e201bfd927f889803c571d - Sigstore transparency entry: 707444826
- Sigstore integration time:
-
Permalink:
iterative/shtab@ca1d284f7fc3f8e0cd6ce41cafb0221cde5f15da -
Branch / Tag:
refs/tags/v1.8.0 - Owner: https://github.com/iterative
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@ca1d284f7fc3f8e0cd6ce41cafb0221cde5f15da -
Trigger Event:
push
-
Statement type: