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

Re: Simplest way to choose one of several commands



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