Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Update _twisted completion



On Mon, 04 Feb 2013 11:48:44 -0500
"Eric P. Mangold" <eric@xxxxxxxxxxxx> wrote:
> Im glad my little innovations have raised these questions. I
> would like very much for there to be a system whereby software authors
> could more easily take charge of supplying their own shell-completion
> functionality as part of the software distribution, instead of relying on
> static functions shipped with zsh. I've seen several other projcts in the
> past that ship/generate their own functions, and we could probably all
> benefit from using an officially supported protocol.

It should be as easy as putting that function in
/usr/share/zsh/site-functions, or equivalent.  That's already in the
fpath ahead of the standard completion directory/directories, so will be
picked up by compinit, which already scans the entire fpath --- that
should be all you need.

There needs to be some interaction between the two utilities so
the utility can supply the information where zsh can find it.  I don't
think it's going to get much simpler than that.

The only difficulty would appear to be ensuring you've got the right
site-functions directory for the version or versions of zsh.  You could
do something like the following on installation:

for testdir in $path; do
  if [[ -x $testdir/zsh ]]; then
    sitefndir="$(zsh -cf 'print -l $fpath' | grep 'site-functions$' | head -1)"
    [[ -d $sitefndir ]] && cp my_completion_files $sitefndir
  fi
done

The alternative is to add some file to an initialisation directory that
sets the fpath for you early on (something run from /etc/zshrc would be
OK, something from /etc/zshenv would be good enough, something only from
/etc/zprofile wouldn't).  Distributions already have ways of doing this
and you probably wouldn't want to reinvent the wheel.

pws



Messages sorted by: Reverse Date, Date, Thread, Author