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

Re: globbing and quoting in a function



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:

> On Jul 20,  7:24am, Stefan Reichör wrote:
> }
> } I'd like to call:
> } lsnew *
> } lsnew a*
> } 
> } Is there an easy way to do it in zsh?
>
> Yes.  It's been answered in the previous postings.
>
>   function lsnew { ls -tr -dl $~1(om[1,30]) }
>   alias lsnew='noglob lsnew'

Thanks for summarizing it. I overlooked the ~ in Doug's message.

I use it now the following way to allow calling without a parameter also:

function lsnew () {
    if [[ $1 = "" ]]; then
        lsnew_glob="*"
    else
        lsnew_glob=$1
    fi
    ls -tr -dl $~lsnew_glob(om[1,30])
}
alias lsnew='noglob lsnew'


Stefan.



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