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

Re: Simplest way to choose one of several commands



On Mon, Sep 7, 2009 at 18:22, Nikolai Weibull <now@xxxxxxxx> wrote:
> Is there a simpler way of doing the following?
>
> alias ls=${${(f)"$(whence -p {g,}ls)"}[1]}' --color'
>
> I need to select gls, if thatâs whatâs installed, otherwise ls.

I ended up doing

alias ls="${commands[gls]:-ls} --color"

It doesnât get shorter that that, it seems.

One might want to do

alias ls="${${commands[gls]##*/}:-ls}

to only get the basename.



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