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 14355
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: Nikolai Weibull <now@xxxxxxxx>
- Subject: Re: Simplest way to choose one of several commands
- Date: Tue, 8 Sep 2009 15:14:42 -0700
- Cc: Sebastian Stark <seb-zsh@xxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxxxxx>
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=d200902; d=spodhuis.org; h=Received:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:Content-Transfer-Encoding:In-Reply-To; b=Z7spGEGkZiwsuOiYIzR4w/aI/SAB6AlabQVov7BNi1Vh46jAtxRtAJeDSeiW4BEJqJqYrFmselm80rT508QD6OdzqTab6gnXEoKOIgYFpImjb1PIydg/RIVcwwg8BW+KIGPP1F6hgfvB1ZLzMWcMxn0oQJsgjIbxFybvvvOBE4A=;
- In-reply-to: <dbfc82860909080234x2d8fb17bue7e8814389b262cd@xxxxxxxxxxxxxx>
- Mail-followup-to: Nikolai Weibull <now@xxxxxxxx>, Sebastian Stark <seb-zsh@xxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <dbfc82860909070922u19535071v17842f1f10ffed4@xxxxxxxxxxxxxx> <D75FF918-CFF5-4244-A6D1-0709210B5F50@xxxxxxxxxxx> <dbfc82860909080234x2d8fb17bue7e8814389b262cd@xxxxxxxxxxxxxx>
On 2009-09-08 at 11:34 +0200, Nikolai Weibull wrote:
> 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.
FWIW, I ended up avoiding stuff based purely on command-name and went to
OS checks for more reliability.
typeset -a _e
_e=('LC_COLLATE=C')
_o=''
if [[ $OSTYPE == (freebsd|darwin)* ]]; then
[[ $TERM == xterm && $OSTYPE == darwin* ]] && _e+=('TERM=xterm-color')
_o='-bCFGTW'
[[ $OSTYPE == freebsd* ]] && _o="${_o}o"
[[ $OSTYPE == darwin* ]] && _o="${_o}O"
elif [[ $(ls --version 2>/dev/null) == *GNU* ]]; then
_o='--color=tty --time-style=long-iso -bCFv'
fi
eval "function l { $_e ls $_o \"\$@\" }"
unset _o _e
Messages sorted by:
Reverse Date,
Date,
Thread,
Author