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

Re: most-recent-file completion and accept-line



Thanks a lot Bart.

When I tried this previously, I could not get it to work, now it kinda works,
so I finally respond.  Except you need to press the key combo twice, once for
all the possible options to appear and after the second press it accepts one of
the listed files.

Perhpas I have something configured that interferes with it?
Any way FWIW, here is my experience:


[eric@pepper ~] 13 $ ls -rt1 delm*
delme_fruitcom__08_04.pdf
delme_fruitcom__08_04.txt
delme_fruitcom__16_04.pdf
delme_fruitcom__16_04.txt
delme_zz___fruitcom_Monday_June_28_2004.pdf
delme_zz___fruitcom_Monday_June_28_2004.txt
delme_zz___fruitcom_Saturday_July_10_2004.pdf
delme_zz___fruitcom_Saturday_July_10_2004.txt
delme_zz___fruitcom_Wednesday_September_15_2004.pdf
delme_zz___fruitcom_Wednesday_September_15_2004.txt
delme.pdf
delme.txt
delme.xml

[eric@pepper ~] 13 $ ls delme<^X^O>
[eric@pepper ~] 13 $ ls delme.pdf
delme.pdf                                             delme_zz___fruitcom_Monday_June_28_2004.pdf
delme.txt                                             delme_zz___fruitcom_Monday_June_28_2004.txt
delme.xml                                             delme_zz___fruitcom_Saturday_July_10_2004.pdf
delme_fruitcom__08_04.pdf                             delme_zz___fruitcom_Saturday_July_10_2004.txt
delme_fruitcom__08_04.txt                             delme_zz___fruitcom_Wednesday_September_15_2004.pdf
delme_fruitcom__16_04.pdf                             delme_zz___fruitcom_Wednesday_September_15_2004.txt
delme_fruitcom__16_04.txt
[eric@pepper ~] 13 $ ls delme.pdf<^X^O>
[eric@pepper ~] 13 $ ls delme.txt
delme.txt

<Yes, it looks a bit weird>

Bart Schaefer said:
> On Thu, 23 Sep 2004, Eric Smith wrote:
> 
> > How do I bind a key combination to complete the most recent file
> > and then automatically run accept-line or <enter> on this
> > filename?
> 
> This seems like an odd question, because any key _combination_ you choose
> will be at least as many keystrokes as typing ctrl-o enter.  Normally you
> want bindings for things that would otherwise take lots of keystrokes.

So I bind your function to ^O 

> However:
> 
> accept-most-recent() {
>   zle most-recent-file && zle .accept-line
> }
> zle -N accept-most-recent
> bindkey '^X^O' accept-most-recent

-- 
Eric Smith



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