Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Quoting with compadd
- X-seq: zsh-users 14095
- From: Simon Haines <simon.haines@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Quoting with compadd
- Date: Wed, 6 May 2009 17:34:05 +1000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:reply-to:received:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=n0K/DbHHdMUcwk9ZLNl8kEa92EVT6BoySPkQ5CaKkhk=; b=v5BloKx/GiUMqgtwPSnS7AbdNv1MnlQT4tI54N7ksSsFiPybpyWAVoj0egsPNaETZo rSxUk7p3m6IIfu3h/bLkGGQGhjsTSF9MHgVC9+KQPxR5jiZQnlQ6TOKEHA3aQs2z0xCe FW4rC9IKYDhB7Z5/1HgBQ0Yl1J1AjDTHVcM1o=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:reply-to:date:x-google-sender-auth:message-id :subject:from:to:content-type:content-transfer-encoding; b=hSzXgnEFnYjGWdxSErhvfSva1eWYvnnxNsgL6/nUmEBB2MkFKw+V2wQXan4nfRCL/D r6OCobgZvGaqjz3+Rs2klDfucbiDFzrcsrt6DVWqicdHME0zxUVSADKEltZjtCyjynpd nNLljwZpePO+7h4Vr30D6ooaV37YnSNiwaswQ=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Reply-to: simon.haines@xxxxxxxxxxxxxxxxxx
- Sender: con.amalgamate@xxxxxxxxx
Hi there, I'm trying to build a completion function for the mighty zsh
to provide filename completion for the 'j' script
(http://github.com/rupa/j/tree/master). It seems whenever I use
compadd, newlines are incorrectly quoted.
This awful attempt is the best I could come up with so far (assuming
'compdef j_complete j')
j_complete() {
local -a dirs
dirs=$(grep -o -e ${words[CURRENT]}'[^|]*' < ~/.j)
compadd $dirs
}
However, the newlines in $dirs are quoted by compadd (as are the
spaces). I'm assuming that compadd would prefer spaces in the
filenames be quoted and newlines turned into spaces. I've tried piping
into sed to manually quote spaces, then into tr to turn newlines into
spaces, but compadd then quotes the lot.
The completion needs to scan the file ~/.j for directories containing
the completion word. The file has the format <dir>|<count>|<time>
(notice non-greedy matching in egrep because of the second '|').
Ideally completion should only be offered where the completion word
matches the beginning of a path or part of a path string that follows
'/'.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author