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

Re: tweaking insert-last-word behavior



2009/11/9 Andy <andy@xxxxxxxxxxx>:
> Hi -
>
> Is there some way to induce selective amnesia in 'insert-last-word'?
>
> Specifically, I get a lot of use out of aliases like
>  alias -g M='| more'
>
> However, if my previous command was
>  % grep bar foo.txt M
> and I'm now breathlessly typing out my next clever interrogation of foo.txt,
> the letter "M" is never, of course, what I actually mean to insert when I
> hit 'ESC-.'
>
> I suspect that many shell users make this mistake at least occasionally when
> a pager is invoked at the end of a command - regardless of whether it's
> aliased.
>
> Ideally I'd love to hear that there's an undocumented 'alias' flag that
> means "invisible to insert-last-word". I presume that'd be a lousy general
> solution to the issue, however.
>
> I assume I could remap it so it compares !$ against a list of strings like
> 'M' and alternately inserts word n-1. Beyond that feeling rather kludgy, I'm
> not quite sure how to do that; it wasn't obvious to me, for instance, how
> one references the word at !(n-1) with zsh.
>
> Maybe I'm thinking about the problem in the wrong way. Is there an easy
> solution?

I have copy-earlier-word bound to the key to the left of insert-last-word, which
lets me select any word of any previous line quite easily.

autoload -U copy-earlier-word
zle -N copy-earlier-word

-- 
Mikael Magnusson



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