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, 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

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,powershell}

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

Examples

See the docs for usage 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):

Contributions

Please do open issues & pull requests! Some ideas:

  • 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.12.1.tar.gz (66.2 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.12.1-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for shtab-1.12.1.tar.gz
Algorithm Hash digest
SHA256 0637338723a8fc08ed1c2fd826d8432229924649c26e3247bb48c53d60ca3bf9
MD5 39a086068968566f3e88b87c4525c692
BLAKE2b-256 ef71ddb3c0a7a86db44d2fb3f9cbac162f7ddbcbf563b4a174963ba2b3d4d819

See more details on using hashes here.

Provenance

The following attestation bundles were made for shtab-1.12.1.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.12.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for shtab-1.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31d07db9c958fbe15edd1d0f3c966a7085766374a11ccc5861b810fcd4ada123
MD5 d4071d5f9deeae44b7a671eff40bde5f
BLAKE2b-256 b33f8bf03f51e920585e207157cb49c5bf8e65a9229297c9ec347a6014eb3d61

See more details on using hashes here.

Provenance

The following attestation bundles were made for shtab-1.12.1-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.

Release history Release notifications | RSS feed

This release

1.12.1 This release

2 files

1.12.0

2 files

1.11.0

2 files

1.10.0

2 files

1.9.3

2 files

1.9.2

2 files

1.9.1

2 files

1.9.0

2 files

1.8.2

2 files

1.8.1

2 files

1.8.0

2 files

1.7.2

2 files

1.7.1

2 files

1.7.0

2 files

1.6.5

2 files

1.6.4

2 files

1.6.3

2 files

1.6.2

2 files

1.6.1

2 files

1.6.0

2 files

1.5.8

2 files

1.5.7

2 files

1.5.6

2 files

1.5.5

2 files

1.5.4

2 files

1.5.3

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.10

2 files

1.3.9

2 files

1.3.8

2 files

1.3.7

1 file

1.3.6

2 files

1.3.5

2 files

1.3.4

2 files

1.3.3

2 files

1.3.2

2 files

1.3.1

2 files

1.3.0

2 files

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

0.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page