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

Re: history expansion

that's a nice idea, thanks Mikael

Pier Paolo Grassi
linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217
founder: https://www.meetup.com/it-IT/Machine-Learning-TO

Il giorno gio 20 feb 2020 alle ore 16:25 Mikael Magnusson <mikachu@xxxxxxxxx>
ha scritto:

> 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