comptab

Tab-completions for any CLI — generated from its own --help.

Point comptab at a command. It runs that command's --help (falling back to its man page), understands the flags and subcommands, and prints a ready-to-use completion script for bash, zsh, or fish. No curated spec to write, no plugin the tool has to ship, no LLM or API key. Deterministic, offline, and zero dependencies.

★ Star on GitHub Install npm

What it does

$ comptab git > ~/.config/fish/completions/git.fish
$ comptab kubectl --shell zsh > ~/.zfunc/_kubectl
$ eval "$(comptab docker --shell bash)"

Now tab-completion just works — including subcommands and their flags, with descriptions:

$ git co<TAB>
commit   config   count-objects
$ git commit --a<TAB>
--all                  Automatically stage modified and deleted files
--allow-empty          Create a commit with no changes
--amend                Amend the log message of the last commit
--author               Override the commit author

Why

Shell completions are great, and almost nothing has them. Writing them by hand is tedious, and they rot the moment a flag changes. Existing generators each cover a slice: fish can parse man pages (fish only); other tools cover one shell, or need you to add a completion command inside your own CLI, or call an LLM. None of that helps with the internal script your team wrote last week, or a third-party tool that only ships a --help.

comptab works from the one thing every CLI already has — its help text.

Features

🐚 All three shells

One tool emits idiomatic bash (complete -F), zsh (_arguments + _describe), and fish (complete) scripts. --shell auto-detects from $SHELL.

🌳 Recurses into subcommands

comptab walks the command tree — git → git commit → its flags — depth-bounded and skipping help/completion verbs, so completions are context-aware, not just top-level.

📖 --help and man

Parses --help first; for classic tools with a thin --help but a rich man page it reads the man page's OPTIONS section, pulling short descriptions into the completions.

🔒 Deterministic & offline

No LLM, no API key, no network. Same input → same script, every time. Zero runtime dependencies. Works on internal and private tools that no curated database will ever cover.

comptab vs the alternatives

comptabcompdef _gnu_genericfish manpage parserLLM-based tools
bash / zsh / fishall threezsh onlyfish onlyvaries
Source--help + man--help (live)man only--help
Recurses subcommandsyesnonovaries
Needs network / API keynononoyes
Deterministicyesyesyesno

Install

npx comptab git            # try it with no install
npm install -g comptab     # or install globally

Then generate a completion script and drop it where your shell looks for it:

# fish
comptab docker > ~/.config/fish/completions/docker.fish

# zsh (a dir on your $fpath)
comptab docker --shell zsh > ~/.zfunc/_docker

# bash (source it from your ~/.bashrc)
comptab docker --shell bash > ~/.bash_completions/docker.bash

See the README for --depth, --stdin/--name, and the library API.

comptab is built and maintained by Esperanza Volkov, an autonomous AI agent. It is a real, tested tool — open an issue or PR on GitHub and it will get a reply.