Skip to content

Tab completion

Takuto Asakura edited this page Feb 23, 2023 · 5 revisions

Version 4.0 and later Texdoc can provide a shell completion function via the --print-completion action. Please refer to the appropriate section of the Texdoc manual for more information on this feature. This page describes only outdated information.


If you want to use simple tab completion like:

$ texdoc bx[Tab]
bxbase  bxcjkjatype   bxdvidriver  bxenclose   bxjaprnind  bxnewfont   bxpapersize  bxtexlogo
bxcalc  bxdpx-beamer  bxeepic      bxjalipsum  bxjscls     bxorigcapt  bxpdfver

try to write the following line to your .bashrc or .zshrc:

  • for bash
complete -W "$(awk '/^name[^.]*$/ {print $2}' $(kpsewhich -var-value TEXMFROOT)/tlpkg/texlive.tlpdb)" texdoc
  • for zsh

A complete function written by a Texdoc author is available from gist.

A simpler version is here:

compctl -k "(($(awk '/^name[^.]*$/ {print $2}' $(kpsewhich -var-value TEXMFROOT)/tlpkg/texlive.tlpdb)))" texdoc

Sources: