From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13700 invoked by alias); 4 Jan 2018 17:48:10 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42223 Received: (qmail 2164 invoked by uid 1010); 4 Jan 2018 17:48:10 -0000 X-Qmail-Scanner-Diagnostics: from mail-it0-f54.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.214.54):SA:0(-2.6/5.0):. Processed in 2.112183 secs); 04 Jan 2018 17:48:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=AHEJF+EETimpmLgSlUYRDR1RqJelSwcj3ZfqtrF/Z0U=; b=Vlbg/kB+US4Af+bi0DhXixsdBICVXV8U8fx+B272d10wgNXmH5kqlnqL79BqnNJ/LU b8R/Qy9BgtnXwz+CUPH9VOts/qcJwWAKAd4SaBPjHA4Bz4nQz7q1LOL3suf1pUkspyJy 4ZO5Q7bmbU5kzHixPXzyG9uqsibEzz6AoXigMGrttppK7YENeV57TawZAgH4s61R04wQ Pag/gtqY1gRAkZNnTid5IdafNrcFLy4UpQxS1fGl+3FdtPp0bsIyhOdZ/ISQtQkLdiMy 63FmD1Gh2uGT4UyPKI2Ij4RmBpiIsLut8QSWCOrSuaDRSoj5tloqVtjEtBH/SwgGHWBX 6MrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=AHEJF+EETimpmLgSlUYRDR1RqJelSwcj3ZfqtrF/Z0U=; b=GA3t+A3xXv4K4lMNBESxnsN+lvK9yA+K3TBzFOBO7bCBQ1OPW/AjoVJCOkN1MLzmA+ s2gv9x1tOtjytiixPKl5QY0k8r49xQRKd9L/aiGq9j/olZuwbreI0QbNrpGWsseLtR4C dOK6Whn79wRiM8GJILXmcEW02FUi9vcdegJIhfn/NcPmbEFhCIgGpfd+xo2eT11rh1+J OvGybaMzLPUGR1AzJ1iX/YuS1R8IDvv20NOWetioxZj8SGMClrm2cjiamXuMVSF8mCQD qHVNK0dlSoaMkZhpMUx8sDG9fdLe/ceXy3xqwJlmtt8qgZcc69JesHGAX9qFUqEEWCl2 I2aQ== X-Gm-Message-State: AKGB3mKkY8va9p5x8dgejnKPZIqomC3kW+W93OgIzUl+AqSumu3LpSVz 4dRN+93mPk3iPjvgIzvfoqdvRjwcy9I= X-Google-Smtp-Source: ACJfBovhq0YK8nY9fgS3M6mvvGS2/FbE+zoguS5+zgDXBt8KSjK2fMEQx4Y6RXBViCb1WWqtqFQhcA== X-Received: by 10.36.82.146 with SMTP id d140mr315474itb.54.1515088084183; Thu, 04 Jan 2018 09:48:04 -0800 (PST) From: dana Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH] Completion batch #4: New UNIX functions Message-Id: <0ED247D6-B6E3-40AB-A59D-DDEFC4083BEE@dana.is> Date: Thu, 4 Jan 2018 11:48:02 -0600 To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3273) As the _cmd_variant stuff is percolating, here's another batch: These = are all new functions belonging to the 'Unix' group. None of them are = particularly complicated. subl is the command-line interface to Sublime Text; the others are = probably self-explanatory. There are several more coreutils-style commands like = this that i intend to do too, but i haven't started on them just yet. As always, let me know if you see anything i've done weird. dana diff --git a/Completion/Unix/Command/_fold = b/Completion/Unix/Command/_fold new file mode 100644 index 000000000..cccdb6c1e --- /dev/null +++ b/Completion/Unix/Command/_fold @@ -0,0 +1,25 @@ +#compdef fold gfold + +local curcontext=3D$curcontext variant +local -a context line state state_descr args +local -A opt_args + +_pick_variant -r variant busybox=3DBusyBox gnu=3D'Free Soft' unix = --version + +args=3D( + '(-b --bytes)'{-b,--bytes}'[count bytes rather than columns]' + '(: -)--help[display help information]' + '(-s --spaces)'{-s,--spaces}'[fold on whitespace]' + '(-w --width)'{-w+,--width=3D}'[specify line width]:line width = (columns or bytes)' + '(: -)--version[display version information]' + '*: :_files' +) + +# Non-GNU variants don't support long options (except BusyBox's --help) +if [[ $variant =3D=3D *busybox* ]]; then # See also: _busybox + args=3D( ${args:#((#s)|*\))(\*|)--^help*} ) +elif [[ $variant !=3D gnu ]]; then + args=3D( ${args:#((#s)|*\))(\*|)--*} ) +fi + +_arguments -s -S : $args diff --git a/Completion/Unix/Command/_getopt = b/Completion/Unix/Command/_getopt new file mode 100644 index 000000000..f6e65f99b --- /dev/null +++ b/Completion/Unix/Command/_getopt @@ -0,0 +1,30 @@ +#compdef getopt ggetopt + +local curcontext=3D$curcontext +local -a context line state state_descr args aopts +local -A opt_args + +# Note: BusyBox getopt is borrowed straight from util-linux, so they're +# basically identical +if _pick_variant busybox=3DBusyBox util-linux=3D'getopt*enhanced' unix = --version; then + args=3D( + '(-a --alternative)'{-a,--alternative}'[allow long options with = single -]' + '(: -)'{-h,--help}'[display help information]' + '*'{-l+,--longoptions=3D}'[specify long options]:long options' + '(-n --name)'{-n+,--name=3D}'[specify program name]:program name' + '(1 -o --options)'{-o+,--options=3D}'[specify short options]:short = options' + '(-q --quiet)'{-q,--quiet}'[suppress getopt(3) error messages]' + '(-Q --quiet-output)'{-Q,--quiet-output}'[suppress normal output]' + '(-s --shell)'{-s+,--shell=3D}'[specify shell quoting = conventions]:shell:(bash csh tcsh sh)' + '(: -)'{-T,--test}'[test for enhanced getopt]' + '(-u --unquoted)'{-u,--unquoted}'[do not quote output]' + '(: -)'{-V,--version}'[display version information]' + '(-o --options)1: :_guard "^-*" "short options"' + '*:argument' + ) + [[ -n $POSIXLY_CORRECT ]] && aopts+=3D( -A '-*' ) +else + args=3D( '1:short options' '*:argument' ) +fi + +_arguments -s -S $aopts : $args diff --git a/Completion/Unix/Command/_install = b/Completion/Unix/Command/_install new file mode 100644 index 000000000..007f4bd27 --- /dev/null +++ b/Completion/Unix/Command/_install @@ -0,0 +1,111 @@ +#compdef install ginstall + +local curcontext=3D$curcontext lx +local -a context line state state_descr common_args args tmp +local -A opt_args val_args + +# These are *almost* common =E2=80=94 non-GNU variants need to remove = the long options +common_args=3D( + '(--backup)-b[create backups of destination files]' + '(-C -c --compare)'{-C,--compare}'[copy files; do nothing if = identical destination file exists]' + '(-C -c --compare)-c[copy files (default)]' + '(-d --directory)'{-d,--directory}'[create directories]' + '(-g --group)'{-g+,--group=3D}'[specify destination file group]: = :_groups' + '(-m --mode)'{-m+,--mode=3D}'[specify destination file mode]: = :_modes' + '(-o --owner)'{-o+,--owner=3D}'[specify destination file owner]: = :_users' + '(-p --preserve-timestamps)'{-p,--preserve-timestamps}'[preserve = modification times]' + '(-s --strip)'{-s,--strip}'[strip binaries]' + '(-v --verbose)'{-v,--verbose}'[output verbosely]' + '*: :_files' +) + +if _pick_variant gnu=3D'Free Soft' unix --version; then + # Hide Linux-specific options on non-Linux platforms + [[ $OSTYPE =3D=3D linux* ]] || lx=3D'!' + args+=3D( + $common_args + '(-b --backup)--backup=3D[create backup; optionally specify = method]:: :->controls' + "${lx}--context=3D[like -Z, or specify SELinux security context to = set]::SELinux security context" + '-D[create all leading destination path components]' + '(: -)--help[display help information]' + "${lx}--preserve-context[preserve SELinux security context]" + '--strip-program=3D[specify program used to strip binaries]:strip = program:_files' + '(-S --suffix)'{-S+,--suffix=3D}'[specify backup suffix]:backup = suffix' + '(-t --target-directory)'{-t+,--target-directory=3D}'[copy source = to specified directory]: :_directories' + '(-T --no-target-directory)'{-T,--no-target-directory}'[treat = destination as regular file]' + '(: -)--version[display version information]' + "${lx}-Z[set SELinux security context on destination files to = default type]" + ) + +else + args+=3D( + ${common_args##((#s)|*\))(\*|)--*} + '-B+[specify backup suffix for -b]:backup suffix' + '-f+[specify destination file flags]: :_flags' + ) + [[ $OSTYPE =3D=3D dragonfly* ]] && args+=3D( + '!-D+[no effect (compatibility with NetBSD)]: :_directories' + '-L+[use user/group database files from specified directory]: = :_directories' + '-l[fall back to system files if user/group not found in -L = directory]' + ) + [[ $OSTYPE =3D=3D netbsd* ]] && { + args+=3D( + '-a+[specify shell command to run on files after install]:shell = command' + '-r[use temporary files to perform safe copy]' + '-S+[specify arguments to pass to strip program]:arguments to = strip program' + ) + # NetBSD has no -v for some reason + args=3D( ${args##((#s)|*\))(\*|)-v*} ) + } + [[ $OSTYPE =3D=3D openbsd* ]] && args+=3D( + '-D[create all leading destination path components]' + '-F[flush installed file contents to disk]' + ) + [[ $OSTYPE =3D=3D (darwin|dragonfly)* ]] && args+=3D( + '-M[disable use of mmap(2)]' + ) + [[ $OSTYPE =3D=3D (freebsd|netbsd)* ]] && args+=3D( + '-D+[specify destination directory used for metadata log]: = :_directories' + '-h+[store digest in metadata log using specified method]: = :->digests' + '(-C -c --compare)-l+[link files (rather than copy) using specified = method]: :->linkflags' + '-M+[log mtree(8) metadata for installed files to specified = file]:metadata log file:_files' + '+N+[use user/group database files from specified directory]: = :_directories' + '-T+[specify mtree(8) tags to store in metadata log]:mtree(8) tags' + '-U[indicate that install is unprivileged]' + ) + [[ $OSTYPE =3D=3D netbsd* ]] || args+=3D( + '-S[use temporary files to perform safe copy]' + ) +fi + +_arguments -s -S : $args && return 0 + +case $state in + controls) + tmp=3D( + {none,off}':never make backups' + {numbered,t}':make numbered backups' + {existing,nil}':make numbered backups if they already exist' + # 'never' actually means 'always'... + {simple,never}':make simple backups' + ) + _describe -t controls 'version control method' tmp && return 0 + ;; + digests) + tmp=3D( none md5 rmd160 sha1 sha256 sha512 ) + [[ $OSTYPE =3D=3D netbsd* ]] && tmp+=3D( sha384 ) + _values 'digest method' $tmp && return 0 + ;; + linkflags) + tmp=3D( + 'h[hard links]' + 's[symlinks]' + 'm[mixed (hard links for files on same file system)]' + 'a[symlinks use absolute path]' + 'r[symlinks use relative path]' + ) + _values -S '' 'link flags' $tmp && return 0 + ;; +esac + +return 1 diff --git a/Completion/Unix/Command/_mktemp = b/Completion/Unix/Command/_mktemp new file mode 100644 index 000000000..d08ca39a8 --- /dev/null +++ b/Completion/Unix/Command/_mktemp @@ -0,0 +1,44 @@ +#compdef mktemp gmktemp + +local curcontext=3D$curcontext variant +local -a context line state state_descr args +local -A opt_args + +_pick_variant -r variant busybox=3DBusyBox gnu=3D'Free Soft' unix = --version + +args=3D( + '(-d --directory)'{-d,--directory}'[make directory instead of file]' + '(: -)--help[display help information]' + '(-p --tmpdir)'{-p+,--tmpdir=3D}'[make relative to specified = directory]: :_directories' + '(-q --quiet)'{-q,--quiet}'[suppress error messages]' + '--suffix=3D[append specified suffix to template]:template suffix' + '-t[interpret template as single path component relative to temp = dir]' + '(-u --dry-run)'{-u,--dry-run}'[print file name only]' + '(: -)'{-V,--version}'[display version information]' + '1: :_guard "^-*" "template name"' +) + +# Non-GNU variants don't support long options (except BusyBox's --help) +if [[ $variant =3D=3D *busybox* ]]; then # See also: _busybox + args=3D( ${args:#((#s)|*\))(\*|)--^help*} ) +elif [[ $variant !=3D gnu ]]; then + args=3D( ${args:#((#s)|*\))(\*|)--*} ) +fi + +[[ $variant =3D=3D gnu ]] || { + # BusyBox, OpenBSD, and Solaris have -p, but -t doesn't take an = argument + if [[ $variant =3D=3D *busybox* ]] || [[ $OSTYPE =3D=3D = (openbsd|solaris)* ]]; then + args=3D( ${args:#((#s)|*\))(\*|)-t*} ) + args+=3D( '-t[generate template relative to temp dir]' ) + # Dragonfly, FreeBSD, and Darwin take an argument to -t and support = any number + # of template files + else + args=3D( ${args:#((#s)|*\))(1:*|(\*|)-t*)} ) + args+=3D( + '-t[generate template relative to temp dir using specified = prefix]:template prefix' + '*: :_guard "^-*" "template name"' + ) + fi +} + +_arguments -s -S : $args diff --git a/Completion/Unix/Command/_subl = b/Completion/Unix/Command/_subl new file mode 100644 index 000000000..012309ad2 --- /dev/null +++ b/Completion/Unix/Command/_subl @@ -0,0 +1,17 @@ +#compdef subl + +local curcontext=3D$curcontext +local -a context line state state_descr +local -A opt_args + +_arguments -s -S : \ + '(-a -n --add --new-window)'{-a,--add}'[add to current window]' \ + '(-b --background)'{-b,--background}'[do not activate application]' \ + '--command[run specified command]:command' \ + '(: -)'{-h,--help}'[display help information]' \ + '(-a -n --add --new-window)'{-n,--new-window}'[open new window]' \ + '--project[load specified project]:project file:_files' \ + '(-s --stay)'{-s,--stay}'[keep application activated]' \ + '(: -)'{-v,--version}'[display version information]' \ + '(-w --wait)'{-w,--wait}'[wait for files to close]' \ + '*:file or directory:_files'