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

Re: suffix alias on a generated file name



zzapper wrote on Sun, Dec 15, 2019 at 16:20:16 -0000:
> Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote in
> news:20191214111751.ot4jd3o5esekqyfb@tarpaulin.shahaf.local2: 
> 
> 
> >> BUT how do I do that without the manual TABing?
> > 
> > What's wrong with
> > 
> > alias NF='gvim *.txt(.om[1])'
> > 
> > ?
> > 
> > 
> That would be a work-around but what I'm looking for is more generic 
> solution perhaps useful for other situations i.e. having generated a 
> filename or command to re-present it to the shell so that I can in this 
> case apply a suffix alias.

I suppose you could wrap the accept-line widget to perform expansion:

    accept-line() { zle expand-word; zle .accept-line -- "$@" 
    zle -N accept-line

(untested)

You could even make it perform repeated expansions until $BUFFER doesn't change.



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