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}
subparser mode: end-users execute your_cli_app completion {bash,zsh}
Examples
FAQs
Not working? Check out frequently asked questions.
Alternatives
-
executes the underlying script every time <TAB> is pressed (slow and has side-effects)
only provides bash completion
-
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
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
File details
Details for the file shtab-1.5.3.tar.gz
.
File metadata
- Download URL: shtab-1.5.3.tar.gz
- Upload date:
- Size: 44.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cdb7b9aa6a0eb48de8820a51b8dccb119e9c8c0d8ce2d666b10e4535df5f588 |
|
MD5 | 9ade7ea764164c5f9fac7f6bbd35f2e9 |
|
BLAKE2b-256 | 54c7aa17657f2a5e499d84a7c74dd21d6050aad2b8a0e4db66bbb18a9b50209c |
Provenance
File details
Details for the file shtab-1.5.3-py2.py3-none-any.whl
.
File metadata
- Download URL: shtab-1.5.3-py2.py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb46824848cfd294f66fa5abf1ba8ce79af9b65ef10790f7df75ce1c31bdf762 |
|
MD5 | e995576e38a46d47cae658946248fb9e |
|
BLAKE2b-256 | 7df74907903b83a43d22416be36a03ebd04b778a051af69ae43271143b2317a3 |