From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29515 invoked from network); 20 Aug 2003 10:34:12 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 20 Aug 2003 10:34:12 -0000 Received: (qmail 28257 invoked by alias); 20 Aug 2003 10:34:02 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18949 Received: (qmail 28243 invoked from network); 20 Aug 2003 10:34:01 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 20 Aug 2003 10:34:01 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [193.109.254.211] by sunsite.dk (MessageWall 1.0.8) with SMTP; 20 Aug 2003 10:34:1 -0000 X-VirusChecked: Checked X-Env-Sender: okiddle@yahoo.co.uk X-Msg-Ref: server-10.tower-36.messagelabs.com!1061375639!70834 X-StarScan-Version: 5.0.7; banners=-,-,- Received: (qmail 23910 invoked from network); 20 Aug 2003 10:34:00 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-10.tower-36.messagelabs.com with SMTP; 20 Aug 2003 10:34:00 -0000 Received: from gmcs3.local ([158.234.142.61]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id h7KAXxHM030217 for ; Wed, 20 Aug 2003 11:33:59 +0100 Received: from gmcs3.local (localhost [127.0.0.1]) by gmcs3.local (8.11.6/8.11.6/SuSE Linux 0.5) with ESMTP id h7KAZiJ05227 for ; Wed, 20 Aug 2003 12:35:45 +0200 To: zsh-workers@sunsite.dk X-VirusChecked: Checked X-StarScan-Version: 5.0.7; banners=.,-,- In-reply-to: <752.1058355009@csr.com> From: Oliver Kiddle References: <752.1058355009@csr.com> Subject: PATCH: Re: du(1) completion and a little $RANDOM problem Date: Wed, 20 Aug 2003 12:35:44 +0200 Message-ID: <5225.1061375744@gmcs3.local> On 16 Jul, Peter wrote: > Guillaume Chazarain wrote: > > Hi list, > > > > Zsh's default completion on the du(1) command is to show only the > > directories, but why? since du can also be used on files. > > It probably deserves it's own completion. Note if you have GNU du you > can: > > compdef _gnu_generic du > > for best results. (I wonder if we could autodetect or at least guess > some of these at startup where guessing wrong isn't too painful?) Well here's a completion function for du then. We perhaps should have completions for all the really standard UNIX stuff that GNU packages as `coreutils'. Trouble is that these are just the sort of things that have slightly different options on every system you look at. Oliver #compdef du if _pick_variant gnu=Free\ Soft unix --version; then _arguments -s \ '(-a --all -s --summarize)'{-a,--all}'[write counts for all files]' \ '--apparent-size[print apparent sizes rather than disc usage]' \ '(-B --block-size -k)'{-B,--block-size=}'[specify block size]:size (bytes)' \ '(-B --block-size -k --apparent-size -b --bytes)'{-b,--bytes}'[equivalent to --apparent-size --block-size=1]' \ '(-c --total)'{-c,--total}'[produce a grand total]' \ '(-D --dereference-args -L --dereference)'{-D,--dereference-args}'[dereference arguments that are symlinks]' \ '(-h --human-readable -H --si)'{-h,--human-readable}'[print sizes in human readable format]' \ '(-H --si -h --human-readable)'{-H,--si}'[human readable form using powers of 1000]' \ '(-B --block-size)-k[use block size of 1k]' \ '(-l --count-links)'{-l,--count-links}'[count sizes many times if hard linked]' \ '(-L --dereference -D --dereference-args)'{-L,--dereference}'[dereference all symlinks]' \ '(-S --separate-dirs)'{-S,--seperate-dirs}'[do not include size of subdirectories]' \ '(-s --summarize --max-depth -a --all)'{-s,--summarize}'[only display total for each argument]' \ '(-x --one-file-system)'{-x,--one-file-system}'[skip directories on different filesystems]' \ \*{-X+,--exclude-from=}'[exclude files matching any pattern in file]:file:_files' \ '*--exclude=[exclude files matching pattern]:pattern' \ '(-s --summarize)--max-depth=[maximum levels to recurse]:levels' \ '(* -)--help[display help information]' \ '(* -)--version[display version information]' \ '*:file:_files' return else # based on $OSTYPE = solaris2.8 local xdev='[skip directories on different filesystems]' if [[ ${commands[$words[1]]:-$words[1]} = *xpg4* ]]; then args=( -x$xdev ) else args=( -d$xdev '-L[dereference symlinks]' "(-a)-o[do not add child directories' usage to parent's total]" ) fi _arguments -s "$args[@]" \ '(-s -o)-a[write counts for all files]' \ '-k[use block size of 1k]' \ '-r[notify about unreadable files/directories]' \ '(-a)-s[only display total for each argument]' \ '*:file:_files' return fi