Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: alias limg='ls *.{jpg,gif}(.N)'
- X-seq: zsh-users 9971
- From: fletch@xxxxxxxxxxxx
- To: zsh-users@xxxxxxxxxx
- Subject: Re: alias limg='ls *.{jpg,gif}(.N)'
- Date: Wed, 1 Mar 2006 09:25:34 -0500 (EST)
- In-reply-to: <20060228234110.GD25687@xxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns9778B72CAF0AFzzappergmailcom@xxxxxxxxxxx> <20060228181747.GB18839@xxxxxxxxxxxxxxxx> <20060228234110.GD25687@xxxxxxxxxxxxxxxxxxx>
> On 2006-02-28 13:17:47 -0500, Chris Johnson wrote:
>> zzapper sent me the following 0.2K:
>> > I was proud of my little alias
>> >
>> > alias limg='ls *.{jpg,gif}(.N)'
>> >
>> > But it has a teeny-weeny fault; if no image is found it lists
>> everything
>> There was some discussion on this in 2004, in which print was suggested
as a replacement to ls. Try:
>> http://www.zsh.org/mla/users/2004/msg00621.html
>
> But ls would be better if you want the possibility to add options:
>
> limg() { ls "$@" *.{jpg,gif}(.N) }
limg () {
local -a images
images=( *.{jpg,gif,png}(.N) )
if [[ $#images -eq 0 ]] ; then
print "No image files found"
else
ls "$@" "$images[@]"
fi
}
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org| Vincent, you should cease askin' \ o.O'
| scary questions." -- Jules =(___)=
| U
Messages sorted by:
Reverse Date,
Date,
Thread,
Author