From 43247252ddeedcf3955b030f2c77064089581cb0 Mon Sep 17 00:00:00 2001 From: dana Date: Mon, 17 Dec 2018 14:49:33 -0600 Subject: 43897: Add/update various completion functions * Update tail to support -q/-v on NetBSD * Add several new functions (with one change needed to _hosts compdefs) --- ChangeLog | 9 +++++ Completion/Darwin/Command/_xcode-select | 10 ++++++ Completion/Unix/Command/_asciidoctor | 42 +++++++++++++++++++++++ Completion/Unix/Command/_asciinema | 59 +++++++++++++++++++++++++++++++++ Completion/Unix/Command/_host | 23 +++++++++++++ Completion/Unix/Command/_mkfifo | 20 +++++++++++ Completion/Unix/Command/_mknod | 45 +++++++++++++++++++++++++ Completion/Unix/Command/_shred | 19 +++++++++++ Completion/Unix/Command/_tail | 9 +++-- Completion/Unix/Command/_tty | 18 ++++++++++ Completion/Unix/Command/_visudo | 12 +++++++ Completion/Unix/Type/_hosts | 2 +- 12 files changed, 264 insertions(+), 4 deletions(-) create mode 100644 Completion/Darwin/Command/_xcode-select create mode 100644 Completion/Unix/Command/_asciidoctor create mode 100644 Completion/Unix/Command/_asciinema create mode 100644 Completion/Unix/Command/_host create mode 100644 Completion/Unix/Command/_mkfifo create mode 100644 Completion/Unix/Command/_mknod create mode 100644 Completion/Unix/Command/_shred create mode 100644 Completion/Unix/Command/_tty create mode 100644 Completion/Unix/Command/_visudo diff --git a/ChangeLog b/ChangeLog index 73168f290..bf954918e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2018-12-17 dana + * 43897: Completion/Darwin/Command/_xcode-select, + Completion/Unix/Command/_asciidoctor, + Completion/Unix/Command/_asciinema, + Completion/Unix/Command/_host, Completion/Unix/Command/_mkfifo, + Completion/Unix/Command/_mknod, Completion/Unix/Command/_shred, + Completion/Unix/Command/_tail, Completion/Unix/Command/_tty, + Completion/Unix/Command/_visudo, Completion/Unix/Type/_hosts: + Add/update various completion functions + * 43895: Completion/Unix/Command/_watch: Complete for procps/-ng watch diff --git a/Completion/Darwin/Command/_xcode-select b/Completion/Darwin/Command/_xcode-select new file mode 100644 index 000000000..a24b1a6f2 --- /dev/null +++ b/Completion/Darwin/Command/_xcode-select @@ -0,0 +1,10 @@ +#compdef xcode-select + +# No -s, no -o+ form options +_arguments : \ + '(-)'{-h,--help}'[display help information]' \ + '(-)'{-v,--version}'[display version information]' \ + '(-)--install[install command-line developer tools]' \ + '(-)'{-p,--print-path}'[display path of active developer directory]' \ + '(-)'{-r,--reset}'[reset to default developer directory]' \ + '(-)'{-s,--switch}'[specify path of active developer directory]:developer directory:_files -/' diff --git a/Completion/Unix/Command/_asciidoctor b/Completion/Unix/Command/_asciidoctor new file mode 100644 index 000000000..3839c7ed3 --- /dev/null +++ b/Completion/Unix/Command/_asciidoctor @@ -0,0 +1,42 @@ +#compdef asciidoctor + +# Notes: +# - We don't offer -v for verbose, even though that works in some cases +# - @todo We don't complete arguments to -E and -r. Unclear how they work. +# Should we offer gem names from `gem list`...? + +_arguments -s -S : \ + '(: * -)'{-h+,--help=}'[display help information]::help topic:(( + manpage\:"dump man page" + ))' \ + '(: * -)'{-V,--version}'[display version information]' \ + '(-q -v --quiet --verbose)'{-q,--quiet}'[reduce output verbosity]' \ + '(-q -v --quiet --verbose)'{-v,--verbose}'[increase output verbosity]' \ + '*'{-a+,--attribute=}'[set/unset specified document attribute]:document attribute' \ + '(-b --backend)'{-b+,--backend=}'[specify backend output format]:backend:( + docbook docbook45 docbook5 html html5 manpage + )' \ + '(-B --base-dir)'{-B+,--base-dir=}'[specify document base directory]:base directory:_files -/' \ + '(-d --doctype)'{-d+,--doctype=}'[specify document type]:document type:( + article book inline manpage + )' \ + '(-D --destination-dir)'{-D+,--destination-dir=}'[specify destination directory]:destination directory:_files -/' \ + '(-e --eruby)'{-e+,--eruby=}'[specify eRuby implementation]:eRuby implementation:(erb erubis)' \ + '(-E --template-engine)'{-E+,--template-engine=}'[specify template engine]:template engine' \ + '--failure-level=[specify minimum logging level to trigger non-zero exit]:failure logging level [FATAL]:( + WARNING ERROR FATAL + )' \ + '*'{-I+,--load-path=}'[add specified directory to load path]:extension directory:_files -/' \ + '(-n --section-numbers)'{-n,--section-numbers}'[auto-number section titles]' \ + '(-o --out-file)'{-o+,--out-file=}'[specify output file]:output file:_files' \ + '(-R --source-directory)'{-R+,--source-dir=}'[specify source directory]:source directory:_files -/' \ + '*'{-r+,--require=}'[require specified library]:Ruby library' \ + '(-s --no-header-footer)'{-s,--no-header-footer}'[suppress document header/footer]' \ + '(-S --safe --safe-mode)'{-S+,--safe-mode=}'[specify safe-mode level]:safe-mode level [unsafe]:( + unsafe safe server secure + )' \ + '(-S --safe-mode)--safe[set safe-mode level to safe]' \ + '(-t --timings)'{-t,--timings}'[display timing information]' \ + '*'{-T+,--template-dir=}'[specify template directory]:template directory:_files -/' \ + '--trace[include backtrace information on errors]' \ + '*:source file:_files' diff --git a/Completion/Unix/Command/_asciinema b/Completion/Unix/Command/_asciinema new file mode 100644 index 000000000..8e94f0d1e --- /dev/null +++ b/Completion/Unix/Command/_asciinema @@ -0,0 +1,59 @@ +#compdef asciinema + +local ret=1 +local -a context line state state_descr help +local -A opt_args + +help=( '(: * -)'{-h,--help}'[display help information]' ) + +_arguments -A '-*' \ + $help \ + '(: * -)--version[display version information]' \ + '1:command:(( + auth\:"link install ID with asciinema.org account" + cat\:"dump full output of recorded session" + play\:"play back recorded session" + rec\:"record session" + upload\:"upload recorded session" + ))' \ + '*:: :->next' \ +&& ret=0 + +[[ $state == next ]] && +case $words[1] in + auth) + _arguments -s -S : $help && ret=0 + ;; + cat|upload) + _arguments -s -S : $help '1::recording file:_files' && ret=0 + ;; + play) + _arguments -s -S : \ + $help \ + '(-i --idle-time-limit)'{-i+,--idle-time-limit=}'[specify max idle time]:max idle time (seconds)' \ + '(-s --speed)'{-s+,--speed=}'[specify playback speed]:speed factor' \ + '1: :->files-urls' \ + && ret=0 + [[ $state == files-urls ]] && + _alternative 'files:recording file:_files' 'urls: :_urls' && + ret=0 + ;; + rec) + _arguments -s -S : \ + $help \ + '(--overwrite)--append[append to existing recording]' \ + '(-c --command)'{-c+,--command=}'[specify command to record]: :_path_commands' \ + '(-e --env)'{-e+,--env=}'[specify environment variables to capture]:environment variable:_sequence _parameters -g "*export*"' \ + '(-i --idle-time-limit)'{-i+,--idle-time-limit=}'[specify max idle time]:max idle time (seconds)' \ + '(-q -y --quiet --yes)'{-q,--quiet}'[suppress notices/warnings (implies -y)]' \ + '--raw[save raw stdout output, without timing or other metadata]' \ + '--stdin[enable stdin (keyboard) recording]' \ + '(-t --title)'{-t+,--title=}'[specify title of recording]:title' \ + '(--append)--overwrite[overwrite existing recording]' \ + '(-y --yes)'{-y,--yes}'[bypass confirmation prompts]' \ + '1::recording file:_files' \ + && ret=0 + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_host b/Completion/Unix/Command/_host new file mode 100644 index 000000000..e1174d46c --- /dev/null +++ b/Completion/Unix/Command/_host @@ -0,0 +1,23 @@ +#compdef host + +# Note: This command is closely related to (and shares some options with) dig +_arguments -s -S -A '-*' : \ + '(: * -)-V[display version information]' \ + '(-6)-4[use IPv4 only]' \ + '(-4)-6[use IPv6 only]' \ + '(-v -t)-a[query for all record types or (with -l) list all zone records]' \ + '(-d -v)'{-d,-v}'[increase output verbosity]' \ + '-c+[specify query class]:query class:compadd -M "m\:{a-z}={A-Z}" - CH CS HS IN' \ + '-C[check SOA consistency]' \ + '-l[list zone records]' \ + '-N+[specify number of dots required to consider host name absolute]:number of dots' \ + '-r[query non-recursively (clear RD bit)]' \ + '-R+[specify number of retries for UDP queries]:number of retries [1]' \ + '-s[do not try next name server after SERVFAIL]' \ + '-t+[specify query type]: :_dns_types' \ + '-T[query via TCP]' \ + '*-m+[specify memory-usage debug flag]:debug flag:(record usage trace)' \ + '(-W)-w[disable query timeout (wait forever)]' \ + '(-w)-W+[specify query timeout]:query timeout (seconds) [5 (UDP), 10 (TCP)]' \ + '1: :_hosts' \ + '2::DNS server:_hosts' diff --git a/Completion/Unix/Command/_mkfifo b/Completion/Unix/Command/_mkfifo new file mode 100644 index 000000000..4f1d8c87e --- /dev/null +++ b/Completion/Unix/Command/_mkfifo @@ -0,0 +1,20 @@ +#compdef mkfifo gmkfifo + +local -a aopts args + +if _pick_variant gnu='Free Soft' unix --version; then + args=( + '(: * -)--help[display help information]' + '(: * -)--version[display version information]' + '(-m --mode)'{-m+,--mode=}'[specify file mode]: :_file_modes' + ) + [[ $OSTYPE == linux* ]] && args+=( + '(--context)-Z[set SELinux security context to default]' + '(-Z)--context=-[like -Z, or specify SELinux security context]:SELinux security context' + ) +else + aopts=( -A '-*' ) + args=( '-m+[specify file mode]: :_file_modes' ) +fi + +_arguments -s -S $aopts : '*:FIFO:_files' $args diff --git a/Completion/Unix/Command/_mknod b/Completion/Unix/Command/_mknod new file mode 100644 index 000000000..902f49b9f --- /dev/null +++ b/Completion/Unix/Command/_mknod @@ -0,0 +1,45 @@ +#compdef mknod gmknod + +# - @todo Major/minor device numbers could be completed using /proc/devices on +# Linux and e.g. `stat -f %Hr /dev/*` on BSD/Darwin +# - @todo Device numbers should not be completed given p or w types + +local -a aopts args + +if _pick_variant gnu='Free Soft' $OSTYPE --version; then + args=( + '(: * -)--help[display help information]' + '(: * -)--version[display version information]' + '(-m --mode)'{-m+,--mode=}'[specify file mode]: :_file_modes' + '1:special file:_files' + '2:special file type:(( + b\:"block (buffered) special file" + {c,u}\:"character (unbuffered) special file" + p\:FIFO + ))' + '3:major device number' + '4:minor device number' + ) + [[ $OSTYPE == linux* ]] && args+=( + '(--context)-Z[set SELinux security context to default]' + '(-Z)--context=-[like -Z, or specify SELinux security context]:SELinux security context' + ) +else + aopts=( -A '-*' ) + args=( + '-F+[specify device-number format]:device-number format:( + native 386bsd 4bsd bsdos freebsd hpux isc linux netbsd osf1 sco solaris + sunos svr3 svr4 ultrix + )' + '1:special file:_files' + '2:special file type:(( + b\:"block-type device" + c\:"character-type device" + w\:"whiteout node" + ))' + '3:major device number' + '4:minor device number' + ) +fi + +_arguments -s -S $aopts : $args diff --git a/Completion/Unix/Command/_shred b/Completion/Unix/Command/_shred new file mode 100644 index 000000000..ce583bee4 --- /dev/null +++ b/Completion/Unix/Command/_shred @@ -0,0 +1,19 @@ +#compdef shred gshred + +_arguments -s -S : \ + '(: * -)--help[display help information]' \ + '(: * -)--version[display version information]' \ + '(-f --force)'{-f,--force}'[bypass lack of write permissions]' \ + '(-n --iterations)'{-n+,--iterations=}'[specify number of overwrites]:overwrites [3]' \ + '--random-source=[get random bytes from specified file]:random source file:_files' \ + '(-s --size)'{-s+,--size=}'[shred specified number of bytes]:bytes' \ + '(--remove)-u[deallocate and remove file after overwriting]' \ + '(-u)--remove=-[like -u, or specify how to remove]::how to remove [wipesync]:(( + unlink\:"use standard unlink call" + wipe\:"like unlink, but obfuscate bytes in name first" + wipesync\:"like wipe, but sync each obfuscated byte to disk" + ))' \ + '(-v --verbose)'{-v,--verbose}'[display progress]' \ + '(-x --exact)'{-x,--exact}'[do not round file sizes up to nearest block]' \ + '(-z --zero)'{-z,--zero}'[add final overwrite with zeros]' \ + '*: :_files' diff --git a/Completion/Unix/Command/_tail b/Completion/Unix/Command/_tail index 599503ab5..3bfbe37ca 100644 --- a/Completion/Unix/Command/_tail +++ b/Completion/Unix/Command/_tail @@ -38,10 +38,13 @@ else ) ;| (freebsd*|darwin*|dragonfly*|netbsd*) - args+=( '(-f -r)-F[implies -f, but also detect file rename]' ) + args+=( + '(-f -r)-F[implies -f, but also detect file rename]' + '(-v)-q[never output headers giving file names]' + ) ;| - (freebsd*|darwin*|dragonfly*) - args+=( '-q[suppress the headers when displaying multiple files]' ) + (netbsd*) + args+=( '(-q)-v[always output headers giving file names]' ) ;; esac fi diff --git a/Completion/Unix/Command/_tty b/Completion/Unix/Command/_tty new file mode 100644 index 000000000..838975098 --- /dev/null +++ b/Completion/Unix/Command/_tty @@ -0,0 +1,18 @@ +#compdef tty gtty + +local -a args + +if _pick_variant gnu='Free Soft' unix --version; then + args=( + '(-)--help[display help information]' + '(-)--version[display version information]' + '(-s --quiet --silent)'{-s,--quiet,--silent}'[suppress normal output]' + ) +else + args=( '-s[suppress normal output]' ) + [[ $OSTYPE == solaris* ]] && args+=( + "-l[display terminal's synchronous line number]" + ) +fi + +_arguments -s -S : $args diff --git a/Completion/Unix/Command/_visudo b/Completion/Unix/Command/_visudo new file mode 100644 index 000000000..2cb6d85a5 --- /dev/null +++ b/Completion/Unix/Command/_visudo @@ -0,0 +1,12 @@ +#compdef visudo + +_arguments -s -S : \ + '(: * -)'{-h,--help}'[display help information]' \ + '(: * -)'{-V,--version}'[display version information]' \ + '(-f --file)'{-f+,--file=}'[specify sudoers file]:sudoers file:_files' \ + + c \ + '(x -c --check)'{-c,--check}'[check sudoers file for errors only]' \ + '(-q --quiet)'{-q,--quiet}'[suppress error messages (with -c)]' \ + '(x -s --strict)'{-s,--strict}'[enable strict checking]' \ + + '(x)' \ + '(c)'{-x+,--export=}'[export sudoers file to specified JSON output file]:JSON output file:_files' diff --git a/Completion/Unix/Type/_hosts b/Completion/Unix/Type/_hosts index d9e1090a4..4057fee10 100644 --- a/Completion/Unix/Type/_hosts +++ b/Completion/Unix/Type/_hosts @@ -1,4 +1,4 @@ -#compdef ftp rwho rup xping traceroute host aaaa zone mx ns soa txt +#compdef ftp rwho rup xping traceroute aaaa zone mx ns soa txt # avoid calling variable "hosts", it's an obvious candidate for use in # zstyle -e '*' hosts 'reply=($hosts)' -- cgit 1.4.1