[texdoc] Almost ready for v3.0!

Reinhard Kotucha reinhard.kotucha at web.de
Fri Jun 1 00:59:40 CEST 2018

On 2018-05-31 at 13:56:08 +0900, Takuto ASAKURA wrote:

 > Hi Denis, Norbert, Paulo, and All,
 > thank you for your useful information.
 > For the future users, I summarized briefly this discussion
 > in the wiki of our GitHub repository:
 > https://github.com/TeX-Live/texdoc/wiki/Tab-completion

Dear Takuto,
thank you very much!

However, the commands are quite inefficient because many programs are
involved.  grep is invoked even twice and zsh also runs tr.  The
latter is not necessary here (zsh 5.0.2 (x86_64-redhat-linux-gnu)).

Paulo, if the command below doesn't work for you and zsh really needs
a space as a delimiter, replace {print $2} with {printf "%s ",$2}' and
let me know.  I can't make zsh a login shell easily and when I invoke
zsh from bash, zsh inherits the environment from bash.  Hence it's
necessary that you test it yourself in a clean environment.

printf() is much more expensive than print() and it would be nice if
it can be avoided, though it's certainly more efficient than to pipe
the results through tr afterwards.

The code Norbert and Paulo provided is using awk only in order to
select a particular column.  But unstead of


you can write in awk

  /regexp/ {action}

and thus you can do everything more efficiently in awk itself without
the need to fork other processes.  I suppose that the solutions below
are much faster on slow machines.  As a side effect, the code is more
compact and more comprehensible.


  complete -W "$(awk '/^name/ {print $2}' $(kpsewhich -var-value TEXMFROOT)/tlpkg/texlive.tlpdb)" texdoc


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

Norbert, do you intend to add a file


to the Debian TeX Live distribution?  That would be great because
completion then works out of the box.  Another advantage is that the
script can assign /path/to/texlive.tlpdb to a variable so that
kpsewhich isn't needed at run-time.


[1] https://www.gnu.org/software/gawk/manual/

[2] Arnold Robbins, Nelson H. F. Beebe: "Classical Shell Scripting",
    Chapter 9, ISBN 978-0-596-00595-5

Reinhard Kotucha                            Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                    mailto:reinhard.kotucha at web.de

More information about the texdoc mailing list