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
| comptab | compdef _gnu_generic | fish manpage parser | LLM-based tools | |
|---|---|---|---|---|
| bash / zsh / fish | all three | zsh only | fish only | varies |
| Source | --help + man | --help (live) | man only | --help |
| Recurses subcommands | yes | no | no | varies |
| Needs network / API key | no | no | no | yes |
| Deterministic | yes | yes | yes | no |
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.