Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: history expansion
- X-seq: zsh-users 24700
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Pier Paolo Grassi <pierpaolog@xxxxxxxxx>
- Subject: Re: history expansion
- Date: Thu, 20 Feb 2020 16:25:27 +0100
- Cc: Zsh-Users List <zsh-users@xxxxxxx>
- In-reply-to: <CAP+y1xAq-MOLtcdHd_q6j8azmWX7FLOg=p9Ff4MxDGU2Q2Ov5A@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAP+y1xA-Pm1-kiuvODNHRteGAEbOOA7PDqR6mYF+v-hvBYiCZA@mail.gmail.com> <CACeGjnUZ_UJAqm=xZbN5Gof+G8M-Y9zATf433FSApV=avp5G1g@mail.gmail.com> <CAP+y1xB3=zPcUhd_qJ3nDBPvx8XOoHPqDn0Btby-r=bBpoOVEg@mail.gmail.com> <CACeGjnX=weLLEp6q4nOur-2U6YfU4E8sxBvmvwyDuZcJ30FDEA@mail.gmail.com> <CAP+y1xAq-MOLtcdHd_q6j8azmWX7FLOg=p9Ff4MxDGU2Q2Ov5A@mail.gmail.com>
On 2/20/20, Pier Paolo Grassi <pierpaolog@xxxxxxxxx> wrote:
> something like an alias that could allow me to reuse history expandable
> expressions, such as !!, !:1, ^cdcd^cddcd and so on
If you make an alias like normal, but instead of pressing enter, press
^Xa (_expand_alias), it should do what you want. This could then be
extended with a custom widget bound to accept-line that checks if the
current input is one of your special history-aliases and expand it for
you before accepting the line, etc.
skeleton example of the latter,
zle -N accept-line accept-line-history-alias
accept-line-history-alias() {
if [[ $BUFFER = histalias-* ]]; then
zle _expand_alias
fi
zle .$WIDGET
}
if you go this route, you could also use a custom lookup assoc array
instead of using aliases.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author