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

Re: refering to 2nd from last history parameter?



On Thu, 22 Jan 2015 12:18:19 +0000
zzapper <david@xxxxxxxxxxxxxx> wrote:
> I don't think it's possible
>
> ls !$    last parameter of previous command
>
> echo a b c d e f g h
>
> I don't think I can grab 'g' without counting left to right

This isn't actually a question :-).  What are you trying to do?  Are you
at the shell command line trying to extract something and don't care if
you use the editor or history, but happen to know there was a way to do
something a bit like this in the history?  I'll assume that but let us
know if that's not the case.

You can use the insert-last-word standard widget (\e. in Emacs mode)
combined with the copy-earlier-word shell widget, which I have bound as

autoload -Uz copy-earlier-word
zle -N copy-earlier-word
bindkey '\e=' copy-earlier-word

Then the answer is that you type "\e." to get the h then "\e=" to go
back to the "g".  I use this all the time.

pws


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