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

tweaking insert-last-word behavior

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?



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