include options in tab completion
this way also things like cppman -s TAB complete and descriptions of the options are printed, e.g. for me
pseyfert@kona:~ > cppman -TAB
option:
--cache-all -c -- Cache all available man pages from cppreference.com and cplusplus.com to enable offline browsing
--clear-cache -C -- Clear all cached files.
--find-page -f -- Find man page.
--force-columns -- Force terminal columns
--force-update -o -- Force cppman to update existing cache when '--cache-all' or browsing man pages that were already cached.
--help -h -- show help message and exit
--pager -p -- Select pager to use.
--rebuild-index -r -- rebuild index database for the selected source.
--source -s -- Select source
--use-mandb -m -- If true, cppman adds manpage path to mandb so that you can view C++ manpages with 'man' command.
--version -v -- Show version information.
simplify completion code (drop eval and perl and use native zsh
code instead)
e.g. to obtain the second word from the current command line W=$(eval echo $words[@]:1}) seems overkill to me (launching a subprocess), where instead W=$words[2] has the same effect. (unless there's something i'm missing). similarly, escaping with printf '%q can be skipped by not calling compadd in eval. Similarly, i dropped the string processing in perl by using paramter expansion (see comments in the code).
use more standard installation / setup location
the old script required being sourced (e.g. during shell launch). A more common way to provide zsh completions is providing a completion definition file in a directory in the fpath that starts with an underscore and provides the compdef command in the first line (see most of the files in https://github.com/zsh-users/zsh/tree/master/Completion) at the same time can be omitted when calling compdef because we're not dealing with pattern matching here.
The renaming will affect packaging, and was already applied in the AUR package https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=cppman#n28
NB: for the install location, I see many packages on debian install in /usr/share/zsh/vendor-completions, the current aur package uses /usr/share/zsh/site-functions . last time I looked into this i ended up with https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=982442 (though this was specific for the debian packaging, not for what location is the best choice for upstream packages.
cppman -s TAB
complete and descriptions of the options are printed, e.g. for meeval
andperl
and use native zsh code instead) e.g. to obtain the second word from the current command lineW=$(eval echo $words[@]:1})
seems overkill to me (launching a subprocess), where insteadW=$words[2]
has the same effect. (unless there's something i'm missing). similarly, escaping withprintf '%q
can be skipped by not callingcompadd
in eval. Similarly, i dropped the string processing in perl by using paramter expansion (see comments in the code).compdef
command in the first line (see most of the files in https://github.com/zsh-users/zsh/tree/master/Completion) at the same time can be omitted when callingcompdef
because we're not dealing with pattern matching here. The renaming will affect packaging, and was already applied in the AUR package https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=cppman#n28NB: for the install location, I see many packages on debian install in /usr/share/zsh/vendor-completions, the current aur package uses /usr/share/zsh/site-functions . last time I looked into this i ended up with https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=982442 (though this was specific for the debian packaging, not for what location is the best choice for upstream packages.