Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Tip of the day: previous command output
- X-seq: zsh-users 7904
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Tip of the day: previous command output
- Date: Sun, 22 Aug 2004 18:10:57 -0700 (PDT)
- In-reply-to: <20040822205801.GM7841@xxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20040819085812.GL22962@localhost> <Pine.LNX.4.61.0408190748530.9464@xxxxxxxxxxxxxxxxxx> <20040819164250.GA21575@xxxxxxxxx> <Pine.LNX.4.61.0408190956440.9464@xxxxxxxxxxxxxxxxxx> <20040820121202.GA31466@xxxxxxxxx> <20040820145032.GH13530@xxxxxxxxxxxxx> <Pine.LNX.4.61.0408200905300.27591@xxxxxxxxxxxxxxxxxx> <20040822205801.GM7841@xxxxxxxxxxxxx>
- Reply-to: zsh-users@xxxxxxxxxx
On Sun, 22 Aug 2004, Vincent Lefevre wrote:
> I mean that instead of expanding to filenames, one expands
> to lines from $kept (but only those that match the pattern).
Aha. So, akin to the case where you've provided a prefix, but instead
you've provided a pattern.
This is almost exactly the same as the _insert_kept widget, so I'll just
edit it to include a test on the $WIDGET name. Like so:
_insert_kept() {
(( $#kept )) || return 1
local action
zstyle -s :completion:$curcontext insert-kept action
if [[ -n $action ]]
then compstate[insert]=$action
fi
if [[ $WIDGET = *expand* ]]
then compadd -U ${(M)kept:#${~words[CURRENT]}}
else compadd -a kept
fi
}
zle -C insert-kept-result complete-word _generic
zle -C expand-kept-result complete-word _generic
zstyle ':completion:*-kept-result:*' completer _insert_kept
This obviously isn't as sophisticated as _expand, which knows how to deal
with all sorts of things besides just patterns. You might also find that
the call to compadd -U needs to have some of the -i -I -P -S options
thrown in to avoid obliterating parts of the word that you didn't mean
to obliterate; I've shown only the most simple solution.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author