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 14366
- From: Nikolai Weibull <now@xxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Simplest way to choose one of several commands
- Date: Sun, 13 Sep 2009 22:57:52 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=tG1uzZ7OqrEtehy+iVVl3tazfakxlRSgoSOvQ2x/i3k=; b=BRmrO0dfOWyXeVwCbjVUuySTiEz7ah40pyERLhhS+ibGRp9Xrkq769jwZAN53JAw0w q2F2Oar3n6T6rEEjFcbHKfy63m/GA6tOVIxQYnkDzjSHc4g4XeUkAmjCO9YIGeM6fG5w 2KGQMvXlgEDu+wpDNwPN3VAB36tR9E/wvNFNY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=Jw/uw9vR0Mh582nvE7AoEKgcvaBClTIiOsAflGUdxb20+scjwxyniV/pAhJvM5ky2t /u/MofH2WY75ExmAFI+1dzcJ2c6KAAAJei6TbchYFtXazSs9l3FGtUYlphcZe3Z6XVBX Hf8dcCB2Xw9e0qMn81Tc8SpuFytrPfrdh5/t8=
- In-reply-to: <dbfc82860909070922u19535071v17842f1f10ffed4@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <dbfc82860909070922u19535071v17842f1f10ffed4@xxxxxxxxxxxxxx>
- Sender: nikolai.weibull@xxxxxxxxx
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