Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: creating a mnemonic for a history command



On Fri, May 17, 2024 at 7:01 AM Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
>
> > On 17/05/2024 12:03 BST Allomorphy <allomorphy@xxxxxxxxx> wrote:
> > This is one of the most useful incantations for me:
> > !?foo?:%
> >
> > What is an elegant way to set up a mnemonic like say an alias or
> > something else to type
>
> Your best bet is probably to use an editor function [...]
>
> gimme() {
>   LBUFFER='!?'$LBUFFER
>   RBUFFER='?:%'$RBUFFER
>   zle accept-line
> }

This widget not only retrieves the word, but executes it as a command,
which it seems to me unlikely to be the intended effect?  I wonder if
the OP would prefer e.g. complete-word instead of accept-line?

Or perhaps (assuming compinit has run) just escape-slash to invoke
_history-complete-older, if that works well enough?




Messages sorted by: Reverse Date, Date, Thread, Author