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

Re: Simplest way to choose one of several commands



On Tue, Sep 8, 2009 at 11:29, Sebastian Stark<seb-zsh@xxxxxxxxxxx> wrote:

> On 07.09.2009, at 18:22, Nikolai Weibull wrote:

>> Is there a simpler way of doing the following?

>> alias ls=${${(f)"$(whence -p {g,}ls)"}[1]}' --color'

> Âfor ls in gls ls; do whence $ls >/dev/null && {alias ls="$ls --color";
> break}; done; unset ls

By simple I meant short.  Your solution is, eh, not short.  ;-)

> Besides this it can be easily extended to adopt handling of different
> platforms (ls --color on darwin wonât work). I think this kind of thing
> needs to be done with less zshisms to be powerful.

Well, thatâs exactly why Iâm doing what Iâm doing.  Choose gls if
thatâs installed, that is, weâre on, for example, Darwin.  Otherwise,
choose ls and hope that weâre on Linux, Cygwin, or similar system
where GNU ls is installed as ls.



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