shtab 1.12.1


pip install shtab

  Latest version

Released: Sep 01, 2026


Meta
Author: Casper da Costa-Luis
Maintainer: tqdm developers
Requires Python: >=3.9

Classifiers

Development Status
  • 5 - Production/Stable

Environment
  • Console
  • MacOS X
  • Other Environment

Intended Audience
  • Developers
  • Education
  • End Users/Desktop
  • Other Audience
  • System Administrators

Operating System
  • MacOS
  • MacOS :: MacOS X
  • POSIX
  • POSIX :: BSD
  • POSIX :: BSD :: FreeBSD
  • POSIX :: Linux
  • POSIX :: SunOS/Solaris
  • Unix

Programming Language
  • Other Scripting Engines
  • Python
  • Python :: 3
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: 3 :: Only
  • Unix Shell

Topic
  • Desktop Environment
  • Education :: Computer Aided Instruction (CAI)
  • Education :: Testing
  • Office/Business
  • Other/Nonlisted Topic
  • Software Development
  • Software Development :: Build Tools
  • Software Development :: Libraries
  • Software Development :: Libraries :: Python Modules
  • Software Development :: Pre-processors
  • Software Development :: User Interfaces
  • System
  • System :: Installation/Setup
  • System :: Shells
  • System :: System Shells
  • Terminals
  • Utilities

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

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies: