zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@sunsite.dk
Subject: PATCH: Re: du(1) completion and a little $RANDOM problem
Date: Wed, 20 Aug 2003 12:35:44 +0200	[thread overview]
Message-ID: <5225.1061375744@gmcs3.local> (raw)
In-Reply-To: <752.1058355009@csr.com>

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


  parent reply	other threads:[~2003-08-20 10:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-16 11:16 Guillaume Chazarain
2003-07-16 11:30 ` Peter Stephenson
2003-07-16 11:46   ` Bart Schaefer
2003-07-16 12:09     ` Sven Wischnowsky
2003-07-17 10:17     ` Oliver Kiddle
2003-08-20 10:35   ` Oliver Kiddle [this message]
2003-08-20 14:22     ` PATCH: " Doug Kearns
2003-08-21 12:35       ` Oliver Kiddle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5225.1061375744@gmcs3.local \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).