--- id: shtab version: "1.10.0" license: MPL-2.0 license_treatment: copyleft maintenance: active --- # shtab — Automagic shell tab completion for Python CLI applications License: copyleft · Maintenance: active · Downloads: 4.6M/mo ## What it is and what it does shtab generates static shell completion scripts for Python CLI applications that use argparse. Instead of executing your application every time a user presses tab (which is slow and can have side effects), shtab analyzes your ArgumentParser once and outputs a completion script that your shell can source. It supports bash, zsh, fish, and tcsh, and handles argument choices, file/directory paths, and dynamic shell commands. You integrate shtab into your CLI in two ways: as a library (add a few lines to your app to expose a --print-completion flag), or as a standalone CLI tool that inspects an external parser object. The package has no runtime dependencies and is actively maintained with support for Python 3.9 through 3.14. Use it for: - Add bash/zsh completion to an existing argparse CLI with minimal code changes - Generate completion scripts for distribution with your application package - Support multiple shells (bash, zsh, fish, tcsh) from a single argparse definition - Enable dynamic completions (e.g., git branch names) without re-executing the CLI on every tab press - Provide completion for subcommands and nested argument groups automatically ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Generates shell tab completion scripts for Python CLI applications built with argparse, supporting bash, zsh, fish, and tcsh without runtime overhead. Yes. shtab is production-stable, actively maintained, has zero security vulnerabilities, and solves a real problem (shell completion) with zero runtime overhead. The copyleft license is not a barrier for using it as a library in your own CLI. Install it if you build Python command-line tools and want to offer your users fast, reliable shell completion. ## Install pip install shtab uv add shtab poetry add shtab ## Installing shtab Before you install: Low friction: pure Python wheel with no runtime dependencies. Active maintenance with a release 7 days ago and 461 repository stars. License in practice: MPL-2.0 (copyleft): you must disclose source modifications and distribute under the same license if you modify and redistribute shtab itself, but using it as a library in your own CLI does not impose restrictions on your application's license. Quickstart: pip install shtab import argparse from shtab import add_argument_to_parser parser = argparse.ArgumentParser() add_argument_to_parser(parser) # End-users then run: your_app --print-completion bash | source Requires Python 3.9 or later; shell completion installation is a separate end-user step (not automatic). Verify before relying: - Whether dynamic shell commands (e.g., git branch completion) work reliably across all supported shells - Performance characteristics when handling very large choice sets or deeply nested subcommands ## Package facts - License: MPL-2.0 (copyleft) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 4.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags shell tab completion generator, argparse bash completion, cli autocomplete script, zsh fish bash completion, python command line completion, shell completion for argparse, cli-tooling, shell-integration [View on SkillFed](https://skillfed.io/packages/shtab) · [View on PyPI](https://pypi.org/project/shtab/)