Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
passing partial command arguments to completion functions
- X-seq: zsh-users 11053
- From: Steve Borho <steve@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: passing partial command arguments to completion functions
- Date: Tue, 5 Dec 2006 07:54:10 -0600
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Ageia Technologies, Inc
Hello everyone,
I have a nit I would like to fix in the Mercurial completion function, as seen
here:
http://www.selenic.com/hg/log/adbf440a81e0/contrib/zsh_completion
The problem is in the way it completes files. Most file completions are
performed by asking mercurial for a list of files that we're interested in,
then passing those files to _wanted. Here's a snippit for how we complete
hg add <TAB>
_hg_status() {
status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 . 2>/dev/null)"})
}
_hg_unknown() {
typeset -a status_files
_hg_status u
_wanted files expl 'unknown files' _multi_parts / status_files
}
_hg_cmd_add() {
_arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
'*:unknown files:_hg_unknown'
}
This will ask mercurial for the list of unknown files in the current directory
`hg status -0nu .` and pass those to _wanted. This works for most normal
cases. Where it falls down is when you're completing a relative path like
this:
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?
--
Steve Borho (steve@xxxxxxxxx)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author