Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Simplest way to choose one of several commands
- X-seq: zsh-users 14350
- From: Sebastian Stark <seb-zsh@xxxxxxxxxxx>
- To: Nikolai Weibull <now@xxxxxxxx>
- Subject: Re: Simplest way to choose one of several commands
- Date: Tue, 8 Sep 2009 11:29:47 +0200
- Cc: Zsh Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <dbfc82860909070922u19535071v17842f1f10ffed4@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <dbfc82860909070922u19535071v17842f1f10ffed4@xxxxxxxxxxxxxx>
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'
I need to select gls, if that’s what’s installed, otherwise ls. (The
code above assumes that at least ls is installed, which isn’t a
problem.)
Since you’re asking for the simplest way I have to come up with this:
for ls in gls ls; do whence $ls >/dev/null && {alias ls="$ls --
color"; break}; done; unset ls
not so cool, but it works and is parseable by humans :)
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.
Sebastian
Messages sorted by:
Reverse Date,
Date,
Thread,
Author