Zsh Mailing List Archive
Messages sorted by:
Re: How does a new software package provide Zsh tab completion scripts to users?
- X-seq: zsh-users 17764
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Robert McLay <mclay@xxxxxxxxxxxxxxx>
- Subject: Re: How does a new software package provide Zsh tab completion scripts to users?
- Date: Wed, 24 Apr 2013 10:00:40 +0100
- Cc: zsh-users@xxxxxxx
- In-reply-to: <CAAH8Jevr7tJj1RzzFupRSsUach-cnzCe3kVbd+6zLsA_TD=dLQ@mail.gmail.com>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CAAH8Jevr7tJj1RzzFupRSsUach-cnzCe3kVbd+6zLsA_TD=dLQ@mail.gmail.com>
On Tue, 23 Apr 2013 16:21:59 -0500
Robert McLay <mclay@xxxxxxxxxxxxxxx> wrote:
> I am the author of a software package and I'd like to provide Zsh tab
> completion scripts for users of my package. In particular my package is
> Lmod. It is updated tool to handle environment modules, similar to but not
> exactly the same as the TCL/C based environment modules. Its main
> advantage is that makes dealing with multiple compilers and MPI stacks much
> easier along with the dependent libraries and applications.
> The problem is that Lmod is typically installed by system administrators
> and not by users directly. There is not a good way to tell the Zsh users
> that there is tab completion scripts available. I also do not think that
> I'll get many site to put my zsh scripts in the system location.
> Eventually if/when Lmod takes over the world (;->), my completion scripts
> will be in the standard zsh installation but until that day, I'd like to
> know what options are available.
Phil gave a fairly full answer, but here's a simple reply to that
specific question... Obviously, the key to avoiding clashes is having a
function name that's as likely to be unique as possible. To make the
function available, it needs to be somewhere in the function path, and
the site function directory is the obvious one because it's designed to
be a standard place to put functions supplied by the local
administrator. However, it depends how zsh was configured. Assuming
it's been configured in a fairly standard manner, and the local
/etc/zshenv isn't doing something it shouldn't, your installation
programme could do:
zshfndir="`zsh -fc 'print -l $fpath' | grep site-functions | head -1`"
and use that directory to install your function. That does the basics;
then you have to worry about more sophisticated things such as
non-standard zsh configurations, whether you're going to be smart
enough to uninstall it, whether you're going to look for your completion
function elsewhere in the path, and whatever paranoia occurs to you.
Putting the file in the right place should be most of the battle
(apart from what you noted next), since the #comdpef lines for
files in the function path are scanned automatically.
> To use Lmod, users must source something that defines a shell function. In
> this file, I could also prepend a directory to FPATH and do
> autoload -U compinit
> compinit -C
> to make the Lmod completion available. However this seems like a bad
> idea. What if a Zsh user is not using tab completion?
I tend to agree; it can take a while to start up as well, and it hooks
in various shell modules providing parameters in the main name space, so
it's not entirely without side effects. I think at this level the user
has to make a decision, and you have to tell the user that zsh
completion is available if they want to use it.
> Has this been discussed before? I did some searching but was unable to
> find anything. I'm not sure what the right phrase would be.
Things like this have come up, though as you say it's kind of hard to
search for. I don't think there was any grand conclusion beyond "there
are ways of doing this".
If there's a killer argument for one way of doing it, we could certainly
add support in the shell distribution to make it easier --- though
having said that you'd almost certainly want something that worked
with older versions of the shell.
Peter Stephenson <p.stephenson@xxxxxxxxxxx> Principal Software
Engineer Tel: +44 (0)1223 434724 Samsung Cambridge
Solution Centre St John's House, St John's Innovation Park,
Cowley Road, Cambridge, CB4 0DS, UK
Messages sorted by: