Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: passing partial command arguments to completion functions
- X-seq: zsh-users 11055
- From: Peter Stephenson <pws@xxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: passing partial command arguments to completion functions
- Date: Tue, 05 Dec 2006 15:20:12 +0000
- In-reply-to: <200612050754.10233.steve@xxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <200612050754.10233.steve@xxxxxxxxx>
Steve Borho wrote:
> hg add ../foo/bar<TAB>
>
> I need to be able to pass the partial path to hg status, but this is
> one notch above my current belt level :) Can anyone give me some
> hints, or point me at some completion functions which do something similar?
The usual way of doing this is to look at $PREFIX in the completion
function. This contains the part of the word to be completed that's
before the cursor.
There are all sorts of uses in the completion system already, though
none of them are particularly simple. See, for example, the
_remote_files function in the _ssh function (Completion/Unix/Command in
the source tree) which tries to get a list of remote files that can be
completed using the existing prefix.
The special parameters used there are described in the zshcompwid manual
page. The code is complicated by subtleties to do with quoting and
whether some part of the prefix is being ignored --- for example, it
assumes the remote host has already been transferred to $IPREFIX because
it's no longer being completed. That's probably not relevant in your
case.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
Messages sorted by:
Reverse Date,
Date,
Thread,
Author