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

Re: tweaking insert-last-word behavior



On Sun, Nov 8, 2009 at 9:11 PM, Andy <andy@xxxxxxxxxxx> wrote:

> 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 use smart-insert-last-word with a match directive:

autoload -U smart-insert-last-word
zle -N insert-last-word smart-insert-last-word
zstyle :insert-last-word match '[^,]??*'

Since I want words that are at least 3 letters long and don't begin with a
comma (all my global aliases use a leading comma, such as ",l" for "| less",
",f" for "| fgrep", etc.).  Since anything really short is not really worth
using insert-last-word for anyway, this tends to do what I expect.  Note
that if no qualifying words are found on a line, smart-insert-last-word just
returns the last word, so don't let that fool you into thinking there is a
bug when there is not.

..wayne..


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