Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completions issues
- X-seq: zsh-users 5157
- From: Borsenkow Andrej <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- To: GoTaR <gotar@xxxxxxxxxxxxxx>
- Subject: Re: completions issues
- Date: 12 Jul 2002 22:44:56 +0400
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20020710204701.GA3362@os>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20020710204701.GA3362@os>
В Чтв, 11.07.2002, в 00:47, GoTaR написал:
> Hi!
>
> I've got some problems with creating my own rule for sms sending
> program. Here comes the significant part:
>
> _sms_aliases () {
> compadd "$@" $(print ${(f)"$(smsaddr -l | cut -f1)"})
> }
> [...]
> _arguments -C \
> '-r[remove existing entry]:SMS alias:_sms_aliases'
>
> smsaddr returns two columns, completion should be done from both, but
> treated as one entry, e. g.:
>
> $ smsaddr -l
> alias1 608612341
> alias2 504147432
> blias3 603648734
>
> $ smsaddr -r a[tab]... lias2
> alias1 608612341
> alias2 504147432
>
> $ smsaddr -r 6[tab]... 08612341
> alias1 608612341
> blias3 603648734
>
> so one column will be used as comment.
>
> I will be very grateful for help.
>
_sms_aliases should check both fields and add the first if any matches.
To prevent completion using own matching use -U flag to compadd.
Something like
ret=1
smsaddr -l | while read alias number; do
if [[ $alias == $PREFIX*$SUFFIX || $number == $PREFIX*$SUFFIX ]]; then
compadd -U -- $alias
ret=0
fi
done
return $ret
with obvious error checking. If you want to add numbers as descriptions,
somebody else better explains how to do it :-)
-andrej
Messages sorted by:
Reverse Date,
Date,
Thread,
Author