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

Re: implicit previous command, only state what should change

On 14 July 2014 00:50, Emanuel Berg <embe8573@xxxxxxxxxxxxx> wrote:
> Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx> writes:
>>> $ grep user-home-directory *.el
>>> After that, I realize that it should have been
>>> `user-emacs-directory'.
>>> Is there a way to tell zsh to "execute the previous
>>> command again, only substitute the first argument for
>>> user-emacs-directory"? Like
>>> $ !!:1->user-emacs-directory
>> Like this:
>> % ^-home-^-emacs-
> I seems that is substitution of the first match sort of
> like the sed substitution command without the g option,
> which actually for this example is much better than my
> suggestion (because only part of the argument is
> incorrect), so it is great to know, yes.
> Still, one can imagine a case when the whole argument
> is wrong, and for a long argument it would be better to
> just be able to refer to it and state the replacement.
> I tried ^!:1^replacement but that wasn't it.
> --
> underground experts united

I would just navigate to the line and word, delete-whole-word-match,
and type the new argument there. (You'll need to autoload, zle -N and
bindkey that to something).

Mikael Magnusson

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