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 14345
- From: Baptiste Daroussin <baptiste.daroussin@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Simplest way to choose one of several commands
- Date: Mon, 7 Sep 2009 23:33:25 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=UEX7MlQrXJGrc4+XAYHxQjupMaB7OoiUDmhfE7GMwTI=; b=l6V09ZPonq+dJLnmxlCTqhQXUvS6/5Ypjp/N8MyiFpMgmIG7fGorp7+1SHuic8yr5t A4ZnzvM/Mw1lviWnir9oEifRKvxVLHmqZHvomBUD9ibxaj+z3ZKGhoykSYppfSAeOBIY u51EIpdyjznw+uEREK6uaV6xLhJ3eMh99fhz4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=DTdY36YMxvaVHmdCXXd7TyV+5hU0ZJTAOWgIay+r5bOJfKkbbxzNmW/BhrtWMwgTAL WQaLBG7EkB1eHy3sGdB2BwlyMmt6OOazkPcSA5CMhI9/uhQ1k0bNVAIFh9EH0vttEr+g TQsF5qCNf1KIkmklPdO2Oa1vm/01GhrZL6iPY=
- In-reply-to: <dbfc82860909070922u19535071v17842f1f10ffed4@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <dbfc82860909070922u19535071v17842f1f10ffed4@xxxxxxxxxxxxxx>
all the command in path are in the associative array $commands so
assuming that at least ls is in the path :
alias ls="${commands[gls]:-$commands[ls]} --color"
it seems simpler to me
2009/9/7 Nikolai Weibull <now@xxxxxxxx>:
> 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.)
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author