diff options
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r-- | Completion/Unix/Command/_arp | 110 | ||||
-rw-r--r-- | Completion/Unix/Command/_chsh | 97 | ||||
-rw-r--r-- | Completion/Unix/Command/_dhclient | 86 | ||||
-rw-r--r-- | Completion/Unix/Command/_git | 4 | ||||
-rw-r--r-- | Completion/Unix/Command/_gpg | 12 | ||||
-rw-r--r-- | Completion/Unix/Command/_ip | 15 | ||||
-rw-r--r-- | Completion/Unix/Command/_mpc | 111 | ||||
-rw-r--r-- | Completion/Unix/Command/_ngrep | 33 | ||||
-rw-r--r-- | Completion/Unix/Command/_route | 254 | ||||
-rw-r--r-- | Completion/Unix/Command/_tcpdump | 177 | ||||
-rw-r--r-- | Completion/Unix/Command/_vmstat | 90 | ||||
-rw-r--r-- | Completion/Unix/Command/_w | 47 | ||||
-rw-r--r-- | Completion/Unix/Command/_who | 64 |
13 files changed, 901 insertions, 199 deletions
diff --git a/Completion/Unix/Command/_arp b/Completion/Unix/Command/_arp index f340e979e..80e829022 100644 --- a/Completion/Unix/Command/_arp +++ b/Completion/Unix/Command/_arp @@ -1,23 +1,103 @@ #compdef arp local state line expl curcontext="$curcontext" ret=1 -local -a cmds +typeset -A opt_args +local -a cmds args -cmds=(-a --display -d --delete -s --set -f --file) +flags=( temp pub ) +cmds=( + '(2 3)-a[show entries for all hosts]' + '(2 -d)-d[delete entry from table]' + '(-n -v)-s[create an arp entry]' + '(2 3 -n -v)-f[read multiple entries from file]' +) +args=( '-n[show numeric addresses]' ) +vopt='-v[be verbose]' -_arguments -C \ - "($cmds 1 -D --use-device)"{-a,--display}'[show entries for all or specified hosts]:host:->hostintable' \ - "($cmds 1 -n --numeric -D --use-device -H --hw-type)"{-d,--delete}'[delete entry from table]:host:->hostintable' \ - "($cmds 1 -n --numeric)"{-s,--set}'[create an ARP entry]:host:_hosts:ethernet address::*:option:(temp trail pub)' \ - "($cmds 1 -n --numeric)"{-f,--file}'[read multiple entries from file]:file:_files' \ - '(-i --device)'{-i,--device}'[select an interface]:::_net_interfaces:' \ - '(-D --use-device -a --display -d --delete)'{-D,--use-device}"[use the interface ifa's hardware address]" \ - '(-H --hw-type -d --delete)'{-H,--hw-type}'[class of entries to check for]:class:(ether arcnet pronet ax25 netrom)' \ - '(-n --numeric -d --delete -s --set -f --file)'{-n,--numeric}'[shows numerical addresses]' \ - '(-v --verbose)'{-v,--verbose}'[be verbose]' \ - '(-a)1:host:->hostintable' && ret=0 +if (( ${+words[(r)-d]} )) && [[ $OSTYPE = (*bsd|dragonfly|darwin)* ]]; then + args+=( '(1 *)-a[delete all entries]' ) +fi -[[ "$state" = hostintable ]] && - _wanted hosts expl 'host' compadd ${${${(f)"$(${words[1]} -an)"}##[ ?(]#}%%[ )]*} && ret=0 +case $OSTYPE in + linux*) + cmds=( + '(2 * -D --use-device)-a[show entries in BSD style output format]' + '!(2 * -D --use-device)-e' + '(2 -n --numeric -D --use-device -H --hw-type)'{-d,--delete}'[delete entry from table]' + '(-n --numeric)'{-s,--set}'[create an ARP entry]' + '(2 * -D --use-device)'{-f,--file}'[read multiple entries from file]' + ) + args=( + '(-i --device)'{-i+,--device=}'[select an interface]:interface:_net_interfaces' + '(-D --use-device -a --display -d --delete)'{-D,--use-device}"[use specified interface's hardware address]" + '(-H --hw-type -d --delete)'{-H+,--hw-type=}'[specify class of entries to check for]:class:(ash ether arcnet pronet ax25 netrom rose dlci fddi hippi irda x25 infiniband eui64)' + '(* -n --numeric -d --delete -s --set -f --file)'{-n,--numeric}'[show numeric addresses]' + '(-v --verbose)'{-v,--verbose}'[be verbose]' + ) + flags+=( netmask ) + ;; + darwin*|freebsd*|dragonfly*) + cmds+=( '(-n -v -i)-S[create an arp entry, replacing any existing entry]' ) + ;| + darwin*|freebsd*) + args+=( '(-s -Q -f)-i+[select an interface]:interface:_net_interfaces' ) + ;| + darwin*) + args+=( + '(-d -s -S -f)-l[show link-layer reachability information]' + '(-d -s -S -f)-x[show extended link-layer reachability information]' + ) + flags+=( reject blackhole only ifscope ) + ;; + dragonfly*) + flags+=( only ) + args+=( '-c:cpu' ) + ;; + netbsd*) + flags+=( proxy ) + args+=( $vopt ) + ;; + freebsd*) + args+=( $vopt ) + flags+=( blackhole reject ) + ;; + openbsd*) + args+=( + '(-a -d -W)-F[overwrite existing entries]' + '(-W)-V+[select the routing domain]:routing domain' + ) + cmds+=( + '(- 1)-W[send the wake on LAN frame]' + ) + flags+=( permanent ) + ;; + solaris*) flags+=( trail permanent) ;; +esac + +_arguments -C -s -S $args \ + '1: :->hostintable' \ + '2:ethernet address' \ + "*: :->flags" \ + + '(cmds)' $cmds && ret=0 + +if [[ "$state" = hostintable ]]; then + if [[ -n $opt_args[(i)-(D|-use-device)] ]]; then + _wanted interfaces expl interface _net_interfaces && ret=0 + elif [[ -n $opt_args[(i)-(f|-file)] ]]; then + _files && ret=0 + elif [[ -n $opt_args[(i)-(s|S|-set)] ]]; then + _hosts && ret=0 + else + _wanted hosts expl 'host' compadd ${${${(f)"$(${words[1]} -an)"}##[ ?(]#}%%[ )]*} && ret=0 + fi +elif [[ "$state" = flags ]]; then + if [[ $words[CURRENT-1] = netmask ]]; then + _message -e netmasks netmask + elif (( $+opt_args[-W] )) || [[ $words[CURRENT-1] = ifscope ]]; then + _wanted interfaces expl interface _net_interfaces && ret=0 + else + _wanted flags expl flag compadd -F line $flags && ret=0 + fi +fi return ret diff --git a/Completion/Unix/Command/_chsh b/Completion/Unix/Command/_chsh index 97552e3ac..006aa82a1 100644 --- a/Completion/Unix/Command/_chsh +++ b/Completion/Unix/Command/_chsh @@ -1,40 +1,67 @@ #compdef chsh chpass + +local variant help=h +local -a args shells + case $OSTYPE in -(darwin*|*bsd*) - _arguments : \ - '-s[Specify user login shell]:shell:(${(Z+Cn+)"$(</etc/shells)"})' \ - "-l[Specify location of user]:node:" \ - "-u[Specify authentication name]:auth user:" \ - "1:user name:_users" + darwin*|*bsd*) + args=( '(-a)-s[specify new login shell]:shell:($shells)' ) + ;| + (free|net|open)bsd*) + args+=( '(-s 1)-a[specify user database entry]:passwd entry' ) + ;| + darwin*) + args+=( + '-l[specify location of user]:location' + '-u[specify authentication name]:auth user' + ) ;; -(linux-gnu) - if { =chsh -v } >&/dev/null - then - local -a opts shells - shells=( $(=chsh -l) ) - _arguments : \ - "(-)-s[Specify your login shell]:shell:($shells)" \ - "(-)--shell[Specify your login shell]:shell:($shells)" \ - "(-)-l[Print shells in /etc/shells]" \ - "(-)--list-shells[Print shells in /etc/shells]" \ - "(-)-u[Print a usage message and exit]" \ - "(-)--help[Print a usage message and exit]" \ - "(-)-v[Print version information and exit]" \ - "(-)--version[Print version information and exit]" \ - "1:user name:_users" - return - fi - # else fall through - ;& -(*) - local s='' - # Use $s to cause all options to be treated as mutually exclusive - [[ $words[CURRENT-1] = -* ]] && s="(-)$words[CURRENT-1]" - # This fiddling with $s is a hack to cause "_arguments : --" to use - # the /etc/shells listing for -s or --shell even when the description - # of that option has been pulled from the GNU --help output. - [[ $words[CURRENT-1] = (-s|--shell) ]] && - s="$s"'[ ]:shell:(${(Z+Cn+)"$(</etc/shells)"})' - _arguments : $s "1:user name:_users" -- + (free|net)bsd*) + args+=( + '(-y)-l[update only the local password file]' + '(-l)-y[force YP database entry to be changed]' + ) + ;| + freebsd*) + args+=( + '-p[specify encrypted password field]:password hash' + '-e[change account expire time]:expiry time' + '-d[specify NIS domain]:domain' + '-h[specify NIS server to query]:NIS server:_hosts' + '-o[force use of RPC-based updates]' + ) + ;; + (linux-gnu) + _pick_variant -r variant util-linux=util-linux suse=pwdutils debian -v + args=( -S : '(-)'{-s+,--shell=}'[specify new login shell]:shell:($shells)' ) + case $variant in + suse|util-linux) + shells=( $(_call_program shells $words[1] -l) ) + args+=( + '(-)'{-l,--list-shells}'[print shells in /etc/shells]' + '(-)'{-v,--version}'[display version information]' + ) + help=u + ;| + util-linux|debian) + args+=( '(-)-'{$help,-help}'[display help information]' ) + ;| + suse) + args+=( + '(-)'{-u,--usage}'[display short usage message]' + '(-)--help[display help information]' + '(-D --binddn)'{-D+,--binddn=}'[specify LDAP disingushed name to bind]:binddn' + '(-P --path)'{-P+,--path=}'[specify path to search for passwd and shadow files]:path:_directories' + '(-q --quiet)'{-q,--quiet}"[don't be verbose]" + '--service=[use specified name service]:service:(files nis nisplus ldap)' + ) + ;; + debian) + args+=( '(-R --root)'{-R+,--root=}'[specify directory to chroot into]:directory:_directories' ) + ;; + esac ;; esac + +(( $#shells )) || shells=( ${(Z+Cn+)"$(</etc/shells)"} ) +_arguments $args '1:user name:_users' diff --git a/Completion/Unix/Command/_dhclient b/Completion/Unix/Command/_dhclient index dafe299d9..10cb551e0 100644 --- a/Completion/Unix/Command/_dhclient +++ b/Completion/Unix/Command/_dhclient @@ -2,27 +2,69 @@ local args -if _pick_variant three=V3 two --help; then - args=( - '-q[quiet]' - '-1[only try once to get a lease]' - '-r[release the current lease]' - '-lf[lease file]:lease file:_files' - '-pf[pid file]:pid file:_files' - '-cf[config file]:config file:_files' - '-sf[script file]:script file:_files' - '-e[env vars to pass to child processes]:env var key value pairs:' - '-s[transmit to specific target instead of broadcast]:server:_hosts' - '-g[force giaddr field]:relay:_hosts' - '-n[do not configure any interfaces]' - '-nw[daemonize immediately rather than wait for IP acquisition]' - '-w[do not exit if there are no interfaces found to configure]' - ) -else - args=( '-e[exit if configuration failed after a certain time]' ) -fi +case $OSTYPE in + (open|free)bsd*) + args+=( + '-c+[specify configuration file]:file:_files' + '-l+[specify leases file]:file:_files' + '-u[reject leases with unknown options]' + ) + ;| + freebsd*) + args+=( + '(-d)-b[immediately move to the background]' + '-p+[specify PID file]:file:_files' + ) + ;; + openbsd*) + args+=( + '-i+[ignore values provided by leases for specified options]:options' + '-L+[specify file to write option data too]:file:_files' + ) + ;; + *) # ISC implementation, used on Linux and NetBSD + args=( + '!(-6 -S -T -P -D -N)-4' + '(-4 -s)-6[use the DHCPv6 protocol]' + '-1[only try once to get a lease]' + '(-d)-nw[daemonize immediately rather than wait for IP acquisition]' + "-m[don't require responding ethernet address of dhcp server to match expectation]" + '-v[verbose log messages]' + "-w[don't exit if there are no interfaces found to configure]" + "-n[don't configure any interfaces]" + '-e[specify env vars to pass to child processes]:env var key value pairs' + '(-x)-r[release the current lease]' + '(-r)-x[stop the running DHCP client without releaseing current lease]' + '-p[specify port to transmit to / listen on]:port:_ports' + '(-6)-s[transmit to specific target instead of broadcast]:server:_hosts' + '-g[force giaddr field]:relay:_hosts' + '-i[use a DUID with DHCPv4 clients]' + '-I[use the standard DDNS scheme]' + '--version[display version number]' + '(-4)-S[use Information-request to get only stateless configuration]' + '(-4)*-T[ask for IPv6 temporary addresses]' + '(-4)-P[enable IPv6 prefix delegation]' + '-D[specify DUID selection method]:DUID:((LL\:link-layer LLT\:link-layer\ plus\ timestamp))' + '(-4)-N[restore normal address query for IPv6]' + '-lf[lease file]:lease file:_files' + '(--no-pid)-pf[pid file]:pid file:_files' + '(-pf)--no-pid[disable writing pid files]' + '-cf[config file]:config file:_files' + '-sf[script file]:script file:_files' + '-4o6[DHCPv4 over DHCPv6 protocol]:port' + "-nc[don't drop capabilities]" + '-B[set the BOOTP broadcast flag in request packets]' + '-C[specify dhcp-client-identifier option]:option' + '(-F)-H[specify host-name option]:host name:_hosts' + '(-H)-F[specify fully qualified hostname option]:host name:_hosts' + '-V[specify vendor-class-identifier option]:option' + '--request-options[specify list of options the client is to request from the server]:options' + '--timeout[specify time after which dhclient will decide that no DHCP servers can be contacted]:timeout' + ) + ;; +esac -_arguments $args \ - '-p[port to transmit to / listen on]:_ports' \ - '-d[force to run in foreground]' \ +_arguments -s -S -A "-*" $args \ + '-q[quiet]' \ + '(-b -nw)-d[remain as a foreground process]' \ ':interface:_net_interfaces' diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 518e6d198..26554de05 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -2027,9 +2027,9 @@ _git-worktree() { case $line[1] in (add) if (( $words[(I)--detach] )); then - args=( ':commit:__git_commits' ) - else args=( ':branch:__git_branch_names' ) + else + args=( ':commit:__git_commits' ) fi _arguments \ '(-f --force)'{-f,--force}'[checkout branch even if already checked out in another worktree]' \ diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg index fe6084f20..d7a8ece4c 100644 --- a/Completion/Unix/Command/_gpg +++ b/Completion/Unix/Command/_gpg @@ -26,7 +26,7 @@ fi [[ $service = gpgv ]] || args+=( '(-e --encrypt)'{-e,--encrypt}'[encrypt data. this option may be combined with --sign]' {-d,--decrypt}'[decrypt file or stdin]' - '(-c --symmetric)'{-c,--symmetric}'[encrypt with symmetric cypher only]' + '(-c --symmetric)'{-c,--symmetric}'[encrypt with symmetric cipher only]' '(-s --sign)'{-s,--sign}'[make a signature]' '*'{-r+,--recipient}'[specify user to encrypt for]:recipient:->public-keys' '(-u --local-user)'{-u+,--local-user}'[use name as the user ID to sign]:user attachment:_users' @@ -52,7 +52,7 @@ fi '--fingerprint[list all keys with their fingerprints]:key attachment:->public-keys' '--list-packets[list only the sequence of packets]' '--gen-key[generate a new pair key]' - '--edit-key[a menu for edit yours keys]:key attachment:->public-keys' + '--edit-key[interactively edit a key]:key attachment:->public-keys' '--sign-key[sign a key]:key attachment:->public-keys' '--lsign-key[sign a key but mark as non-exportable]:key attachment:->public-keys' '--delete-keys[remove key from public keyring]:key attachment:->public-keys' @@ -60,12 +60,12 @@ fi '--delete-secret-and-public-keys:key attachment:->secret-keys' '--gen-revoke[generate a revocation certificate]' '--desig-revoke[generate a designated revocation certificate]' - '--export[export all key from all keyrings]' + '--export[export all keys from all keyrings]' '--send-keys[send keys to a keyserver]:key attachment:->public-keyids' '--export-secret-keys:key attachment:->secret-keys' '--export-secret-subkeys:key attachment:->secret-keys' - '--import[import a gpg key from a file]:_files attachment:_files' - '--fast-import[import a file without build trustdb]:_files attachment:_files' + '--import[import a gpg key from a file]:attachment (file):_files' + '--fast-import[import a file without adding to trustdb]:attachment (file):_files' '--fetch-keys[fetch key at URIs]:uri:' '--recv-keys[receive a list of keys from a keyserver]:key attachment:->public-keyids' '--refresh-keys[update all keys from a keyserver]' @@ -82,7 +82,7 @@ fi '--gen-random:count' '--gen-prime' '--warranty[print warranty info]' '(-a --armor)'{-a,--armor}'[create ASCII armored output]' - '--default-key[specify default user-id for signatures]:key:->secret-keys' + '--default-key[specify default user ID for signatures]:key:->secret-keys' '--default-recipient[specify default recipient]:recipient:->public-keys' '--default-recipient-self[use default key as default recipient]' '--no-default-recipient[reset default recipient]' diff --git a/Completion/Unix/Command/_ip b/Completion/Unix/Command/_ip index 6e1cc3b78..74101c646 100644 --- a/Completion/Unix/Command/_ip +++ b/Completion/Unix/Command/_ip @@ -530,15 +530,30 @@ args=( /$'[^\0]#\0'/ ) +# TODO: +# -b*atch <FILENAME> +# -force (for batch mode) +# -l*oops <COUNT> +# -n*etns <NETNS> +# -rc, -rcvbuf<SIZE> _regex_words options "ip options" \ '-h*uman:output statistics with human readable values' \ '-i*ec:print human readable rates in IEC units (ie. 1K = 1024)' \ '-s*tatistics:output statistics' \ + '-d*etails:output more detailed information' \ + '-c*olor:color output' \ + '-a*ll:executes specified command over all objects' \ '-f*amily:select protocol family:$subcmd_family' \ '-4:IPv4' \ '-6:IPv6' \ + '-B:family bridge' \ + '-D:family DECnet' \ + '-I:family IPX' \ + '-M:family MPLS' \ '-0:link protocol, no networking' \ '-o*neline:output one record per line' \ + '-t*imestamp:display current time when using monitor option' \ + '-ts*hort:display current time in shorter format when using monitor option' \ '-r*esolve:use system resolver for DNS names' args+=("$reply[@]" "#") diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc index e0c6888b0..fee5e06f4 100644 --- a/Completion/Unix/Command/_mpc +++ b/Completion/Unix/Command/_mpc @@ -1,4 +1,4 @@ -#compdef mpc +#compdef mpc -value-,MPD_HOST,-default local OUT foo MPD_MUSIC_DIR MPC_PLAYLIST_MATCHER MPC_FORMAT_STRING @@ -26,13 +26,17 @@ _mpc_command() { mpc_cmds=( add:"append a song to the end of the current playlist" + cdprev:"compact disk player-like previous command" + channels:"list the channels that other clients have subscribed to" clear:"clear the current playlist" + clearerror:"clear the current error" crop:"remove all songs except for the currently playing song" current:"show the currently playing song" crossfade:"set and display crossfade settings" del:"remove a song from the current playlist" - disable:"disable a output" - enable:"enable a output" + disable:"disable an output" + enable:"enable an output" + toggleoutput:"toggle an output" idle:"wait until an event occurs" idleloop:"loop waiting for events" insert:"insert a song after the currently playing song in the playlist" @@ -40,6 +44,8 @@ _mpc_command() { load:"load file as a playlist" ls:"list the contents of specified directory" lsplaylists:"list currently available playlists" + mixrampdb:"set and display mixrampdb settings" + mixramdelay:"set and display mixrampdelay settings" move:"move song in playlist" next:"play the next song in the current playlist" outputs:"show the current outputs" @@ -51,10 +57,14 @@ _mpc_command() { repeat:"toggle repeat mode, or specify state" single:"toggle single mode, or specify state" consume:"toggle consume mode, or specify state" + replaygain:"set or display the replay gain mode" rm:"remove a playlist" save:"save a playlist to file" search:"search for a song" + searchadd:"search songs and add them to the current playlist" + searchplay:"search and play songs from the current playlist" find:"search for a song, exact match" + findadd:"find songs and add them to the current playlist" list:"list all tags of given type" seek:"seek to the position specified in percent" shuffle:"shuffle the current playlist" @@ -65,13 +75,18 @@ _mpc_command() { version:"report version of MPD" volume:"set volume" status:"display MPD status" + sendmessage:"send a message to the specified channel" + waitmessage:"wait for at least one message on the specified channel" + subscribe:"subscribe to the specified channel and continuously receive messages" + sticker:"sticker management" ) if (( CURRENT == 1 )); then - _describe -t commands "mpc command" mpc_cmds + _describe -t commands "mpc command" mpc_cmds || \ + _wanted commands expl "mpc command" compadd loadtab tab lstab else local cmd=$words[1] - local curcontext="${curcontext%:*}:mpc-${cmd}" ret=1 + local curcontext="${curcontext%:*:*}:mpc-${cmd}:" ret=1 if ! _call_function ret _mpc_$cmd; then _default && ret=0 fi @@ -100,13 +115,13 @@ _mpc_helper_songnumbers() { NM="$compstate[nmatches]" fi - out=("${(@f)$(_call_program song-numbers mpc $foo playlist)}") + out=("${(@f)$(_call_program song-numbers $mpccmd $foo playlist)}") out=("${(@M)out[@]:#${~MATCH}}") sn=("${(@)${(@M)out}//(#b)(#s)(\#|[ >]#)([0-9]#)*/$match[2]}") list=("${(@Mr:COLUMNS-1:)out}") - _wanted -V 'song numbers' expl 'song number' \ + _wanted -V song-numbers expl 'song number' \ compadd "$@" -ld list "$all[@]" -a sn && ret=0 if [[ -n "$all" ]]; then @@ -131,8 +146,8 @@ _mpc_helper_songnumbers() { (( $+functions[_mpc_helper_playlists] )) || _mpc_helper_playlists() { local list expl - list=(${(f)"$(mpc lsplaylists)"}) - _wanted list expl playlist compadd -M $MPC_PLAYLIST_MATCHER $expl -a list + list=(${(f)"$(_call_program playlists $mpccmd lsplaylists)"}) + _wanted playlists expl playlist compadd -M $MPC_PLAYLIST_MATCHER $expl -a list } (( $+functions[_mpc_helper_files] )) || @@ -142,12 +157,13 @@ _mpc_helper_files() { return fi - local -U list expl + local -U list expl prefix=$PREFIX if [[ $words[CURRENT] != */* ]]; then - list=( ${${(f)"$(mpc listall)"}%%/*}) + list=( ${${(f)"$(_call_program files $mpccmd listall)"}%%/*}) _wanted files expl file compadd -qS/ -a list else - list=(${(f)"$(mpc tab $words[CURRENT])"}) + [[ $compstate[quote] = [\'\"] ]] && prefix="$compstate[quote]$PREFIX$compstate[quote]" + list=(${(f)"$($mpccmd tab -- ${(Q)prefix} 2>/dev/null)"}) _wanted files expl file _multi_parts / list fi } @@ -159,12 +175,13 @@ _mpc_helper_directories() { return fi - local -U list expl + local -U list expl prefix=$PREFIX if [[ $words[CURRENT] != */* ]]; then - list=( ${${(M)${(f)"$(mpc listall)"}:#*/*}%%/*}) + list=( ${${(M)${(f)"$(_call_program directories $mpccmd listall)"}:#*/*}%%/*}) _wanted directories expl directory compadd -qS/ -a list else - list=(${(f)"$(mpc lstab $words[CURRENT])"}) + [[ $compstate[quote] = [\'\"] ]] && prefix="$compstate[quote]$PREFIX$compstate[quote]" + list=(${(f)"$($mpccmd lstab -- ${(Q)prefix} 2>/dev/null)"}) _wanted directories expl directory _multi_parts / list fi } @@ -172,7 +189,7 @@ _mpc_helper_directories() { (( $+functions[_mpc_helper_outputs] )) || _mpc_helper_outputs() { local vals outline - vals=(${${${${(M)${(f)"$(mpc outputs 2> /dev/null)"}:#Output * \(*\) is (en|dis)abled}##Output }%%\) is (en|dis)abled}/ \(/:}) + vals=(${${${${(M)${(f)"$(_call_program outputs $mpccmd outputs)"}:#Output * \(*\) is (en|dis)abled}##Output }%%\) is (en|dis)abled}/ \(/:}) _describe -t outputs output vals } @@ -200,6 +217,10 @@ _mpc_disable() { _mpc_helper_outputs } +_mpc_toggleoutput() { + _mpc_helper_outputs +} + _mpc_move() { if (( $#words <= 3 )); then _mpc_helper_songnumbers @@ -216,22 +237,41 @@ _mpc_ls() { _mpc_helper_directories } +_mpc_lstab() { + _mpc_helper_directories +} + _mpc_load() { _mpc_helper_playlists } +_mpc_loadtab() { + _mpc_helper_playlists +} + _mpc_save() { _mpc_helper_playlists } +_mpc_tab() { + _mpc_helper_files +} + _mpc_rm() { _mpc_helper_playlists } _mpc_volume() { - local expl - compset -P '[-+]' - _wanted list expl volume compadd $expl - {0..100} + local expl value="${${$(_call_program volume $mpccmd volume)#*:}%\%}" ret=1 + if [[ -prefix \+ && $value -lt 100 ]]; then + _wanted -V volume expl volume compadd $expl - +{1..$((100-value))} && ret=0 + elif [[ -prefix - && $value -gt 0 ]]; then + _wanted -V volume expl volume compadd $expl - -{1..$value} && ret=0 + else + _wanted -V volume expl volume compadd $expl - {0..100} && ret=0 + compstate[insert]=menu:$((value+1)) + fi + return ret } _mpc_repeat() { @@ -250,6 +290,10 @@ _mpc_consume() { _mpc_helper_bool } +_mpc_current() { + _arguments --wait +} + _mpc_search() { local list expl list=(album artist title track name genre date composer performer comment disc filename any) @@ -273,7 +317,28 @@ _mpc_update() { _mpc_helper_files } -_arguments \ - '--format[specify the format of song display]:format string' \ - '--no-status[prevent printing song status on completion]' \ - '*::mpc command:_mpc_command' +if [[ $service = *MPD_HOST* ]]; then + _hosts + return +fi + +local curcontext="$curcontext" state line expl ret=1 +local mpccmd="$words[1]" + +_arguments -C \ + '(-q --quiet --no-status -v --verbose)'{-v,--verbose}'[give verbose output]' \ + '(-q --quiet --no-status -v --verbose)'{-q,--quiet,--no-status}'[prevent printing song status on completion]' \ + '(-h --host)'{-h,--host=}'[connect to specified host]:_hosts' \ + '(-p --port)'{-p,--port=}'[connect to server port]:port' \ + '(-f --format)'{-f,--format=}'[specify the format of song display]:format string:->formats' \ + '(-w --wait)'{-w,--wait}'[wait for operation to finish (e.g. database update)]' \ + '*::mpc command:_mpc_command' && ret=0 + +if [[ $state = formats ]]; then + compset -P '([^%]|%[^%]#%)#' + _wanted metadata expl 'metadata delimiter' compadd -p % -S % \ + artist album albumartist comment composer date disc genre performer title \ + track time file position mtime mdate && ret=0 +fi + +return ret diff --git a/Completion/Unix/Command/_ngrep b/Completion/Unix/Command/_ngrep new file mode 100644 index 000000000..924597826 --- /dev/null +++ b/Completion/Unix/Command/_ngrep @@ -0,0 +1,33 @@ +#compdef ngrep + +_arguments -s -S \ + '(- 1 *)-h[display help information]' \ + '(- 1 *)-V[display version information]' \ + "-q[be quiet (don't print packet reception hash marks)]" \ + '-e[show empty packets]' \ + '-i[ignore case]' \ + '-v[invert match]' \ + "-R[don't do privilege revocation logic]" \ + '(-W)-x[print in alternate hexdump format]' \ + '-X[interpret match expression as hexadecimal]' \ + '-w[word-regex (expression must match as a word)]' \ + "-p[don't go into promiscuous mode]" \ + '-l[make stdout line buffered]' \ + '-D[replay pcap_dumps with their recorded time intervals]' \ + '-t[print timestamp every time a packet is matched]' \ + '-T[print delta timestamp every time a packet is matched specify twice for delta from first match]' \ + "-M[don't do multi-line match (do single-line match instead)]" \ + '(-d -s)-I+[read packet stream from pcap format file]:file:_files' \ + '-O+[dump matched packets in pcap format file]:file:_files' \ + '-n+[look at only specified number of packets]:packets' \ + '-A+[dump specified number of context packets after a match]:packets' \ + '(-I)-s+[set the bpf caplen]:length (bytes) [65535]' \ + '-S+[set the upper limit on size of packets matched]:size (bytes)' \ + '(-x)-W+[set the dump format]:packet display format:(normal byline single none)' \ + '-c+[force the column width to the specified size]:columns' \ + '-P+[set the non-printable display char to what is specified]:character [.]' \ + '-F+[read the bpf filter from the specified file]:file:_files' \ + '-N[show sub protocol number]' \ + '(-I)-d+[use specified device instead of the pcap default]:interface:_net_interfaces' \ + '1: :_guard "^-*" pattern' \ + '*::expression:_bpf_filters' diff --git a/Completion/Unix/Command/_route b/Completion/Unix/Command/_route new file mode 100644 index 000000000..f8426874c --- /dev/null +++ b/Completion/Unix/Command/_route @@ -0,0 +1,254 @@ +#compdef route + +local curcontext="$curcontext" expect ret=1 +local -a state state_descr line args families modifiers ignore sub sequential tags +local -A opt_args subcmds once params + +subcmds=( + add 'add a route' + flush 'remove all routes' + delete 'delete a specific route' + change 'change aspects of a route (such as its gateway)' + get 'lookup route for a destination' + monitor 'continuously report any changes to the routing information' +) +args=( + '-n[output addresses numerically]' + '(-q)-v[verbose output]' +) +modifiers=( + '-net:interpret destination as a network' + '-host:interpret destination as a host' +) +params=( + '-dst' target # does this definitely follow + '(-|)netmask' netmask + '(gw|-gateway)' gateway + metric metric + '(mss|window|-(send|recv)pipe)' size:bytes + '[i-]rtt' time:ms + -rttvar rttvar + -mtu mtu + '(dev|-ifscope|-ifp)' interface + -ifa address + -expire time:epoch + -hopcount hopcount + -tag tag + -prefixlen bits + '-(label|push|pop|swap)' label + -priority number # is it a number + -secattr secattr + '(-iw|-iwmax|-msl)' value + '-fib' table +) + +case $OSTYPE in + ^linux*) + args+=( '(-v)-q[suppress all output]' ) + families=( -inet -inet6 ) + modifiers+=( + '-dst:distinguish a destination' + '-gateway:distinguish a gateway address' + -netmask + -rtt -rttvar + -sendpipe -recvpipe + -mtu -hopcount + -expire + '-lock' '-lockrest' + -i{,nter}face:'indicate destination is directly reachable' + '-static:manually added route' + '-nostatic:pretend route added by kernel or daemon' + '-reject:emit an ICMP unreachable when matched' + '-blackhole:silently discard packets (during updates)' + '-proto1:set protocol specific routing flag #1' + '-proto2:set protocol specific routing flag #2' + ) + sequential=( target gateway netmask ) + ;| + *bsd*|darwin*|dragonfly*) + modifiers+=( + -link '-ifp' '-ifa' # do these need an argument: interface or address + '-prefixlen:indicate mask bits' + ) + ;| + (net|free)bsd*|darwin*|dragonfly*) + families+=( -xns ) + modifiers+=( '-xresolve:emit mesg on use (for external lookup)' ) + ;| + (net|open)bsd*|darwin*|dragonfly*) + modifiers+=( + '-cloning:generate a new route on use' + '-llinfo:validly translate proto addr to link addr' + ) + ;| + (open|free)bsd*|darwin*|dragonfly*) + args+=( + "-d[debug-only mode: don't update routing table]" + '-t[test-only mode: /dev/null used instead of a socket]' + ) + ;| + netbsd*|solaris*) + args+=( '-f[remove all routes first]' ) + ;; + (netbsd|darwin|dragonfly)*) + modifiers+=( '-proxy:make entry a link level proxy' ) + ;| + (netbsd|openbsd|dragonfly)*) + subcmds+=( show 'print out the routing table' ) + families+=( -mpls ) + ;| + (netbsd|darwin)*) + families+=( -atalk ) + ;| + (freebsd|darwin)*) + families+=( -osi ) + ;| + (openbsd|dragonfly)*) + modifiers+=( -push -pop -swap ) + ;| + freebsd*) + subcmds+=( + del $subcmds[delete] + show $subcmds[get] + ) + args+=( + '(-6)-4[specify IPv4 address family]' + '(-4)-6[specify IPv6 address family]' + ) + families+=( -4 -6 ) + modifiers+=( '-fib:specify a routing table' ) + ;; + netbsd*) + subcmds+=( flushall 'remove all routes including the default gateway' ) + args+=( + '-S[print a space when a flag is missing to align flags]' + '-s[suppress all output from get except for the gateway]' + ) + modifiers+=( + '-tag' + '-noreject:clear reject flag' + '-noblackhole:clear blackhole flag' + ) + ;; + openbsd*) + subcmds+=( exec 'execute a command with alternate routing table' ) + args+=( + '-T+[select specified alternate routing table]:table id' + ) + modifiers+=( + -sa + '-label' + '-priority' + '-mpath:multiple gateways for a destination exist' + -mplslabel -in -out + ) + ;; + solaris*) + subcmds+=( show 'display list of routes applied at system startup' ) + args+=( + '-p[make changes to the route tables persistent across system restarts]' + '-R+[specify alternate root directory where changes are applied]:directory:_directories' + ) + modifiers+=( + "-private:don't advertise this route" + '-multirt:create the specified redundant route' + '-setsrc:assign the default source address' + '-secattr:security attributes' + ) + ;; + darwin*) + modifiers+=( -ifscope ) + ;| + dragonfly*) + modifiers+=( -iw -iwmax -msl ) + ;| + linux*) + args+=( + '(H -n)--numeric[output addresses numerically]' + '(H)*'{-e,--extend}'[display other/more information]' + '!(H -C --cache)'{-F,--fib} + '(H -C --cache)'{-C,--cache}'[display routing cache instead of FIB]' + + '(family)' + '-A+[use specified address family]:address family:(inet inet6 ax25 netrom ipx ddp x25)' + -4 -6 --inet --inet6 --ax25 --netrom --ipx --ddp --x25 + + '(H)' + '(1 *)'{-h,--help}'[display help information]' + '(1 *)'{-V,--version}'[display version information]' + ) + subcmds[del]=$subcmds[delete] + unset 'subcmds[monitor]' 'subcmds[get]' 'subcmds[change]' + modifiers+=( + netmask gw metric mss window irtt reject mod dyn reinstate + 'dev:force route to be associated with the specified device' + ) + sequential=( target interface ) + ;; +esac + +print -v sub -f '%s\\:%s' ${(kvq)subcmds} +_arguments -C -s -S "1:command:(($sub))" '*::args:->args' $args && ret=0 + +[[ -n $opt_args[(i)-[46]] ]] && families=() + +if [[ -n $state ]]; then + if [[ $line[1] = exec ]]; then + shift words + (( CURRENT-- )) + _normal + elif [[ $line[1] = (flush|monitor) ]]; then + sequential=() + fi + + for ((i=2;i<CURRENT;i++)); do + if [[ -n $expect ]]; then + sequential=( ${sequential:#$expect} ) + expect='' + continue + fi + + expect=${params[(K)$words[i]]} + if [[ -n $expect ]]; then + ignore+=( ${(Q)words[i]} ) + else + if [[ -n ${(M)${families%%:*}:#${(q)words[i]}} ]]; then + families=() + elif [[ -n ${(M)${modifiers%%:*}:#${(q)words[i]}} ]]; then + ignore+=( ${(q)words[i]} ) + elif [[ $words[1] != -lock ]]; then + shift sequential + fi + fi + done + + [[ -z $expect ]] && tags=( modifiers families ) + _tags values $tags + while _tags; do + if _requested values; then + case ${expect:-$sequential[1]} in + target) + if [[ -z $expect ]]; then + _wanted -x targets expl target compadd default && ret=0 + else + _message -e targets target + fi + ;; + interface) _net_interfaces && ret=0 ;; + size:bytes) _guard "[0-9]#" 'size (bytes)' ;; # _guard usage pointless + time:ms) _guard "[0-9]#" 'time (ms)' ;; + time:microseconds) _guard "[0-9]#" 'time (microseconds)' ;; + time:epoch) _guard "[0-9]#" 'expiration time (seconds since epoch)' ;; + rttvar) _guard "[0-9]#" 'time variance (microseconds)' ;; + mtu) _guard "[0-9]#" 'max MTU (bytes)' ;; + hopcount) _guard "[0-9]#" 'hop count' ;; + ssthresh) _message -e threshold 'ss threshold' ;; + bits) _guard "[0-9]#" 'bits' ;; + *) _guard "[^-]#" "${expect:-$sequential[1]}" ;; + esac + fi + _requested modifiers && _describe -t modifiers modifier modifiers -F ignore && ret=0 + _requested families expl 'address family' compadd -a families && ret=0 + (( ret )) || break + done +fi + +return ret diff --git a/Completion/Unix/Command/_tcpdump b/Completion/Unix/Command/_tcpdump index 2c1d82226..4b9950fa5 100644 --- a/Completion/Unix/Command/_tcpdump +++ b/Completion/Unix/Command/_tcpdump @@ -1,17 +1,25 @@ #compdef tcpdump -typeset -A opt_args +local args ret=1 +local root +(( EUID )) && root='!' -_interfaces() { - local disp expl sep - _description interfaces expl 'network interface' - _net_interfaces "$expl[@]" - if zstyle -t ":completion:${curcontext}:interfaces" verbose; then - zstyle -s ":completion:${curcontext}:interfaces" list-separator sep || sep=-- - disp=( "any $sep capture on all interfaces" ) - compadd "$expl[@]" -ld disp any +_tcpdump_interfaces() { + local disp expl sep interfaces + [[ $OSTYPE != openbsd* ]] && + interfaces=( ${${${${(f)"$(_call_program interfaces tcpdump -D)"}#<->.}//[()]/}/ /:} ) + if (( $#interfaces )); then + _describe -t interfaces 'network interface' interfaces else - compadd "$expl[@]" any + _description interfaces expl 'network interface' + _net_interfaces "$expl[@]" + if zstyle -t ":completion:${curcontext}:interfaces" verbose; then + zstyle -s ":completion:${curcontext}:interfaces" list-separator sep || sep=-- + disp=( "any $sep capture on all interfaces" ) + compadd "$expl[@]" -ld disp any + else + compadd "$expl[@]" any + fi fi } @@ -40,43 +48,50 @@ _esp_secrets () { } _packet_types () { + local -a types types=( - 'cnfp[Cisco NetFlow protocol]' - 'rpc[Remote Procedure Call]' - 'rtp[Real-Time Applications protocol]' - 'rtcp[Real-Time Applications control protocol]' - 'vat[Visual Audio Tool]' - 'wb[distributed White Board]' + 'cnfp:Cisco NetFlow protocol' + 'rpc:Remote Procedure Call' + 'rtp:Real-Time Applications protocol' + 'rtcp:Real-Time Applications control protocol' + 'vat:Visual Audio Tool' + 'wb:distributed White Board' ) if [[ $OSTYPE = openbsd* ]]; then types+=( - 'sack[RFC 2018 TCP Selective Acknowledgements Options]' - 'vrrp[Virtual Router Redundancy Protocol]' - 'tcp[Transmission Control Protocol]' + 'sack:RFC 2018 TCP Selective Acknowledgements Options' + 'vrrp:Virtual Router Redundancy Protocol' + 'tcp:Transmission Control Protocol' ) else types+=( - 'aodv[Ad-hoc On-demand Distance Vector protocol]' - 'carp[Common Address Redundancy Protocol]' - 'radius[RADIUS]' - 'snmp[Simple Network Management Protocol]' - 'tftp[Trivial File Transfer Protocol]' - 'vxlan[Virtual eXtensible Local Area Network]' - 'zmtpl[ZeroMQ Message Transport Protocol]' + 'aodv:Ad-hoc On-demand Distance Vector protocol' + 'carp:Common Address Redundancy Protocol' + 'radius:RADIUS' + 'snmp:Simple Network Management Protocol' + 'tftp:Trivial File Transfer Protocol' + 'vxlan:Virtual eXtensible Local Area Network' + 'zmtpl:ZeroMQ Message Transport Protocol' ) fi - _values 'Packets type' $types + _describe -t packet-types 'packet type' types +} + +_time_stamp_types () { + local vals + vals=( ${${${(ps:\n :)"$(_call_program time-stamp-types tcpdump -J ${(kv)opt_args[(i)-i|--interface]} 2>&1)"}[2,-1]:#*cannot be set*}/ /:} ) + _describe -t time-stamp-types "time stamp type" vals } _data_link_types () { - if (( $+opt_args[-i] )); then - vals=( ${${${(s: :)"$(_call_program data-link-types tcpdump -L -i $opt_args[-i] 2>&1)"}[2,-1]}/ /:} ) - _describe -t data-link-types "data link types ($opt_args[-i])" vals && ret=0 - else - _values "Data link types (general)" \ - "EN10MB" \ - "LINUX_SLL" - fi + local vals expl + if (( $+opt_args[(i)-i|--interface] )); then + vals=( ${${${(s: :)"$(_call_program data-link-types tcpdump -L ${(kv)opt_args[(i)-i|--interface]} 2>&1)"}[2,-1]}/ /:} ) + _describe -t data-link-types "data link type (${(v)opt_args[(i)-i|--interface]})" vals + else + _wanted data-link-types expl "data link type (general)" \ + compadd EN10MB LINUX_SLL + fi } _bpf_filter () { @@ -84,79 +99,95 @@ _bpf_filter () { args=( '-A[print each packet in ASCII]' - '-c[exit after receiving specified number of packets]:number of packets' + '-c+[exit after receiving specified number of packets]:number of packets' '(-ddd)-d[dump the compiled packet-matching code in a human readable form]' '(-ddd)-dd[dump packet-matching code as a C program fragment]' '(-d -dd)-ddd[dump packet-matching code as decimal numbers (preceded with a count)]' "-E[decrypting IPsec ESP packets]:spi@ipaddr::algo\:secret:_esp_secrets" '-e[print the link-level header on each dump line]' - '-F[input file for the filter expression]:filter expression file:_files' + '-F+[specify input file for the filter expression]:filter expression file:_files' "-f[print 'foreign' IPv4 addresses numerically]" '-l[make stdout line buffered]' "-N[don't print domain name qualification of host names]" - "-n[don't convert addresses to names]" + "(-nn)-n[don't convert addresses to names]" "-O[don't run the packet-matching code optimizer]" - "-p[don't put the interface into promiscuous mode]" + '(-p --no-promiscuous-mode)'{-p,--no-promiscuous-mode}"[don't put the interface into promiscuous mode]" '-q[quick (quiet?) output]' - '-r[read packets from file]:input file:_files' - '-S[print absolute TCP sequence numbers]' - '-s[specify number of bytes of data to snarf from each packet]:number of bytes to snap' - '-T[interpret captured packets as specified type]:packet type:_packet_types' + '-r+[read packets from file]:input file:_files' + '(-S --absolute-tcp-sequence-numbers)'{-S,--absolute-tcp-sequence-numbers}'[print absolute TCP sequence numbers]' + '-T+[interpret captured packets as specified type]:packet type:_packet_types' "(-tt -ttt -tttt -ttttt)-t[don't print a timestamp on each dump line]" '(-t -ttt -tttt -ttttt)-tt[print an unformatted timestamp on each dump line]' '(-vv -vvv)-v[slightly more verbose output]' '(-v -vvv)-vv[more verbose output]' - '-w[write the raw packets to file]:output file:_files' + '-w+[write the raw packets to file]:output file:_files' '-X[print each packet (minus its link level header) in hex and ASCII]' '-x[print each packet (minus its link level header) in hex]' - '-y[set the data link type to use while capturing packets]:data link type:_data_link_types' - '*:BPF filter:_bpf_filter' + '(-y --linktype)'{-y+,--linktype=}'[set the data link type to use while capturing packets]: :_data_link_types' ) if [[ $OSTYPE = openbsd* ]]; then - args+=( + args=( + '-i+[specify interface]:interface:_tcpdump_interfaces' + - listd + '-L[list data link types for the interface]' + - capture + ${(R)args:#(|\*)(|\(*\))--*} # removes any long-options '(-n)-a[attempt to convert network and broadcast addresses to names]' '-D[select packet flowing in specified direction]:direction:(in out)' '-I[print the interface on each dump line]' '-o[print a guess of the possible operating system(s)]' + '-s+[specify amount of data to snarf from each packet]:length (bytes) [116]' '(-t -tt -tttt -ttttt)-ttt[print day and month in timestamp]' '(-t -tt -ttt -ttttt)-tttt[print timestamp difference between packets]' '(-t -tt -ttt -tttt)-ttttt[print timestamp difference since the first packet]' ) else - args+=( - '-B[specify the capture buffer size in KiB]:capture buffer size' + args=( + '(-i --interface -D --list-interfaces)'{-i+,--interface=}'[specify interface]:interface:_tcpdump_interfaces' + - listt + '(-J --list-time-stamp-types)'{-J,--list-time-stamp-types}'[list supported time stamp types]' + - listd + '(-L --list-data-link-types)'{-L,--list-data-link-types}'[list data link types for the interface]' + - capture + $args + '(-B --buffer-size)'{-B+,--buffer-size=}'[set the operating system capture buffer size]:size (kiB)' '-b[print the AS number in BGP packets in ASDOT notation]' - '-C[specify output file size in MB (10e6 bytes)]:output file size' - '(-* *)'-D'[print the list of the network interfaces available on the system]' - '-G[specify the interval to rotate the dump file in seconds]:dump file rotate seconds' + '-C+[specify output file size]:output file size (MB)' + '(-)'{-D,--list-interfaces}'[print the list of the network interfaces available on the system]' + '-G+[rotate dump file specified with -w at specified interval]:interval (seconds)' '-H[attempt to detect 802.11s draft mesh headers]' - '(-* *)-h[print version strings and a usage message]' + '(- *)'{-h,--help}'[display help information]' + '(- *)--version[display version information]' + '(-I --monitor-mode)'{-I,--monitor-mode}'[put the Wi-Fi interface in monitor mode]' + '--immediate-mode[deliver packets to tcpdump as soon as they arrive without buffering]' '-I[put the interface in monitor mode]' - '(-* *)-J[list the supported timestamp types]' - '-j[set the timestamp type]:timestamp type' - "-K[don't attempt to verify checksums]" - '*-m[load SMI MIB module definitions]:SMI MIB module definitions:_files' - '-M[shared secret for validating the digests in TCP segments with the TCP-MD5 option]:secret' - '-R[assume ESP/AH packets to be based on old specification (RFC1825 to RFC1829)]' - '(-t -tt -tttt)-ttt[print a delta (in micro-seconds) between current and previous line on each dump line]' - '(-t -tt -ttt)-tttt[print a timestamp in default format proceeded by date on each dump line]' - '(-t -tt -ttt -tttt)-ttttt[print a delta (micro-second resolution) since the first line on each dump line]' - '-U[make output packet-buffered when saving to file (-w)]' + '(-j --time-stamp-type)'{-j+,--time-stamp-type=}'[set the time stamp type for the capture]: :_time_stamp_types' + '--time-stamp-precision=[set the time stamp precision for the capture]:precision [micro]:(micro nano)' + '(-K --dont-verify-checksums)'{-K,--dont-verify-checksums}"[don't verify IP, TCP, or UDP checksums]" + '*-m+[load SMI MIB module definitions]:SMI MIB module definition:_files' + "(-n)-nn[don't convert protocol and port numbers to names]" + '-M+[specify shared secret for validating the digests in TCP segments with the TCP-MD5 option]:secret' + '(-# --number)'{-\#,--number}'[print an optional packet number at the beginning of the line]' + '(-O --no-optimize)'{-O,--no-optimize}"[don't run the packet-matching code optimizer]" + '(-s --snapshot-length)'{-s+,--snapshot-length=}'[specify amount of data to snarf from each packet]:length (bytes) [65535]' + '(-t -tt -tttt -ttttt)-ttt[print a delta (in micro-seconds) on each line since previous line]' + '(-t -tt -ttt -ttttt)-tttt[print a timestamp in default format preceded by date on each dump line]' + '(-t -tt -ttt -tttt)-ttttt[print a delta (in micro-seconds) on each line since first line]' + '(-U --packet-buffered)'{-U,--packet-buffered}'[make output packet-buffered when saving to file (-w)]' '-u[print undecoded NFS handles]' - '-V[Read a list of filenames from file]:file:_files' + '-V+[read a list of filenames from specified file]:file:_files' '(-v -vv)-vvv[most verbose output]' - '-W[limit the number of created files (-C)]:number of files' + '-W+[limit the number of created files (-C)]:number of files' '(-X)-XX[print each packet, including its link level header, in hex and ASCII]' '(-x)-xx[print each packet, including its link level header, in hex]' - '-Z[drops privileges (if root) and changes user ID (along with primary group)]:user:_users' - '-z[command to run after file rotation]:command:_command_names' + "${root}(-Z --relinquish-privileges)"{-Z+,--relinquish-privileges=}'[drop privileges and run as specified user]:user:_users' + '-z+[specify command to run on files (with -C or -G)]:command:_command_names -e' ) fi +[[ $OSTYPE = freebsd* ]] && args+=( + '-R[assume ESP/AH packets to be based on old specification (RFC1825 to RFC1829)]' +) -_arguments : \ - '-i[interface]:interface:_interfaces' \ - - optL \ - '-L[list the known data link types for the interface]' \ - - default \ - $args +_arguments -s $args \ + '*::BPF filter:= _bpf_filters' diff --git a/Completion/Unix/Command/_vmstat b/Completion/Unix/Command/_vmstat index 7082cbbd5..7d3008592 100644 --- a/Completion/Unix/Command/_vmstat +++ b/Completion/Unix/Command/_vmstat @@ -4,28 +4,31 @@ local -a specs case $OSTYPE in *linux*) specs=( - '(-a --active)'{-a,--active}'[active/inactive memory]' - '(-f --forks)'{-f,--forks}'[number of forks since boot]' - '(-m --slabs)'{-m,--slabs}'[slabinfo]' - '(-n --one-header)'{-n,--one-header}'[do not redisplay header]' - '(-s --stats)'{-s,--stats}'[event counter statistics]' - '(-d --disk)'{-d,--disk}'[disk statistics]' - '(-D --disk-sum)'{-D,--disk-sum}'[summarize disk statistics]' - '(-p --partition)'{-p,--partition}'[partition specific statistics]:partition:_files' - '(-S --unit)'{-S+,--unit}'[define display unit]:unit prefix:(( k\:1000 K\:1024 m\:1000000 M\:1048576 ))' '(-w --wide)'{-w,--wide}'[wide output]' '(-t --timestamp)'{-t,--timestamp}'[show timestamp]' - '1:delay' '2:count' + '(-n --one-header)'{-n,--one-header}'[do not redisplay header]' + '(-S --unit)'{-S+,--unit=}'[specify unit for displayed sizes]:unit prefix [K]:((k\:1000 K\:1024 m\:1000000 M\:1048576))' + '1: :_guard "[0-9]#" "interval (seconds)"' '2:count' + + '(action)' \ + '(- :)'{-h,--help}'[display help information]' + '(- :)'{-V,--version}'[display version information]' + {-a,--active}'[show active/inactive memory]' + '(- :)'{-f,--forks}'[show number of forks since boot]' + '(-S --unit -t --timestamp -w --wide)'{-m,--slabs}'[show slabinfo]' + '(-w --wide -n --one-header -t --timestamp :)'{-s,--stats}'[show event counter statistics]' + {-d,--disk}'[show disk statistics]' + {-p+,--partition=}'[show partition specific statistics]:partition:_files -W /dev -g "*(-%)"' + '(- :)'{-D,--disk-sum}'[summarize disk statistics]' ) ;; - freebsd*|openbsd*) + *bsd*) specs=( - '-c[number of times to refresh the display]:count' + '-c+[specify number of times to refresh the display]:count' '-f[report on the number fork syscalls since boot and pages of virtual memory for each]' '-i[report the number of interrupts taken by devices since boot]' - '-M[source file to extract values associated with the name list from]:core:_files' - '-N[source file to extract the name list from]:system:_files' - '-w[specify delay between each display]:delay (seconds)' + '-M+[specify core file to extract values associated with the name list from]:core:_files' + '-N+[specify file to extract the name list from]:system:_files' + '-w+[specify delay between each display]:delay (seconds)' '*:disk:_files' ) ;| @@ -35,23 +38,60 @@ case $OSTYPE in '-h[human readable memory columns output]' '-H[scriptable memory columns output]' '-m[report on the usage of kernel dynamic memory allocated using malloc(9) by type]' - '-n[change the maximum number of disks to display]:number of disks to display' + '-n+[change the maximum number of disks to display]:number of disks to display' '-o[list virtual memory objects]' '-P[report per-cpu system/user/idle cpu statistics]' - '-p[specify which types of devices to display]: :->devices' - '-s[display the contents of the SUM structure]:sum' + '-p+[specify which types of devices to display]: :->devices' + '-s[display the contents of the SUM structure]' '-z[report on memory used by the kernel zone allocator, uma(9), by zone]' ) - ;; - openbsd*) + ;| + (net|open)bsd*) specs+=( '-m[report usage of kernel dynamic memory listed first by size of allocation then type of usage]' - '-s[display the contents of the UVMEXP structure]:uvmexp' - '-t[report on the number of page in and page reclaims since boot]' + '-s[display the contents of the UVMEXP structure]' '-v[print more verbose information]' + ) + ;| + openbsd*) + specs+=( + '-t[report on the number of page in and page reclaims since boot]' '-z[include statistics about all interrupts]' ) ;; + netbsd*) + specs+=( + '-C[report on kernel memory caches]' + '-e[report the values of system event counters]' + '-H[report all hash table statistics]' + '-h+[dump specified hash table]:hash table:->hashes' + '-L[list all hash tables]' + '-l[list UVM histories maintained by the kernel]' + '-t[display contents of the vmtotal structure]' + '-U[dump all UVM histories]' + '-u+[dump specified UVM history]:uvm' + '-W[print more information about kernel memory pools]' + ) + ;; + freebsd*|solaris*) + specs+=( + '::disk:_files -W /dev -g "*(-%b)"' + ': :_guard "[0-9]#" "interval (seconds)"' ':count' + ) + ;| + solaris2.<11->) + specs+=( '(-i -s)-T+[specify time format]:time format:((u\:seconds\ since\ epoch d\:standard\ date\ format))' ) + ;& + solaris*) + specs+=( + '-q[suppress messages related to state changes]' + + '(actions)' \ + '(-T)-i[report the number of interrupts taken by devices since boot]' + '-p[report paging activity]' + '(-T)-s[display the total number of system events since boot]' + '-S[report on swapping rather than paging activity]' + ) + ;; esac if (( $#specs )); then @@ -73,7 +113,11 @@ if (( $#specs )); then 'SCSI[Small Computer System Interface devices]' 'other[any other device interface]' 'pass[passthrough devices]' ) - _values -C -s , 'device type' "$types[@]" && ret=0 + _values -s , 'device type' "$types[@]" && ret=0 + elif [[ $state == hashes ]]; then + local -a tables + tables=( ${${${(f)"$(_call_program hashes $words[1] -L)"}[2,-1]#?}/ ##/:} ) + _describe -t hashes 'hash table' tables && ret=0 fi return ret fi diff --git a/Completion/Unix/Command/_w b/Completion/Unix/Command/_w new file mode 100644 index 000000000..8fb4154c7 --- /dev/null +++ b/Completion/Unix/Command/_w @@ -0,0 +1,47 @@ +#compdef w + +local args + +case $OSTYPE in + linux*) + args=( + '(H -f --from)'{-f,--from}'[toggle display of remote hostname]' + '(H -h)--no-header[suppress the heading]' + '(H -i --ip-addr)'{-i,--ip-addr}'[display IP address instead of hostname]' + '(H -o --old-style -s --short)'{-o,--old-style}'[old style output format]' + '(H -s --short -o --old-style)'{-s,--short}'[use short output format]' + '(H -u --no-current)'{-u,--no-current}'[ignore the username while figuring out the current process and cpu times]' + + H + '(-)--help[display help information]' + '(-)'{-V,--version}'[display version information]' + ) + ;; + *bsd*|darwin*|dragonfly*) + args+=( '-i[sort output by idle time]' ) + ;| + openbsd*) + args+=( '-a[translate network addresses into names]' ) + ;| + (free|net)bsd*|dragonfly*) + args+=( '-n[show network addresses as numbers]' ) + ;| + *bsd*|dragonfly*) + args+=( + '-M+[extract values from specified core]:core file:_files' + '-N+[extract name list from specified system]:system file:_files' + ) + ;| + freebsd*|dragonfly*) + args+=( '-d[dump process list on a per controlling tty basis]' ) + ;| + solaris*) + args+=( '!(-s -w -l)'{-l,-w} + '-s[short output form]' + '(-)-u[produce only the heading line]' + ) + ;| +esac + +_arguments -S -s \ + '(--no-header)-h[suppress the heading]' \ + '*:user:_users' $args diff --git a/Completion/Unix/Command/_who b/Completion/Unix/Command/_who new file mode 100644 index 000000000..1f901af18 --- /dev/null +++ b/Completion/Unix/Command/_who @@ -0,0 +1,64 @@ +#compdef who gwho + +local args variant + +_pick_variant -r variant gnu=GNU $OSTYPE --version + +case $variant in + gnu) + args=( + '(Q -a --all -b --boot -d --dead -l --login -p --process -q --count -r --runlevel -t --time -T -w --mesg --message --writable -u --users)'{-a,--all}'[same as -b -d --login -p -r -t -T -u]' + '(Q -b --boot)'{-b,--boot}'[print time of last system boot]' + '(Q -d --dead -a --all)'{-d,--dead}'[print dead processes]' + '(Q -H --heading)'{-H,--heading}'[print line of column headings]' + '(Q -l --login)'{-l,--login}'[print system login processes]' + '(Q)--lookup[canonicalize hostnames via DNS]' + '(Q)-m[print information about current terminal]' + '(Q -p --process)'{-p,--process}'[print active processes spawned by init]' + '(Q -r --runlevel)'{-r,--runlevel}'[print current runlevel]' + '(Q -t --time)'{-t,--time}'[print last system clock change]' + '(Q -T -w --mesg --message --writable)'{-T,-w,--mesg,--message,--writable}"[show user's message acceptance status as +, - or ?]" + '(Q -u --users)'{-u,--users}'[show idle time]' + '!(Q -a)-s' '!(Q -a)--short' + + Q + '(-)'{-q,--count}'[print only login names and number of users logged on]' + '(-)--help[display help information]' + '(-)--version[display version information]' + ) + ;; + darwin*|dragonfly*|netbsd*|solaris*) + args=( + '(Q -a)-d[print dead processes]' + '(Q -a)-l[print system login processes]' + '(Q -a)-p[print active processes spawned by init]' + '(Q -a)-r[print current runlevel]' + '(Q -a)-t[print last system clock change]' + ) + ;| + dragonfly*|netbsd*) + args+=( '(Q)-v[show process exit status, session id etc]' ) + ;| + (net|free)bsd*|darwin*|dragonfly*|solaris*) + args+=( + '(Q -b -d -p -r -T -u)-a[print all entries]' + '(Q -a)-b[print time of last system boot]' + '!(Q -a)-s' + ) + ;| + *) + args+=( + '(Q)-H[print line of column headings]' + '(Q)-m[print information about current terminal]' + "(Q -a)-T[show user's message acceptance status as +, - or ?]" + '(Q -a)-u[show idle time]' + + Q '(-a -b -d -H -l -m -p -r -s -t -T -v)-q[print only login names and number of users logged on]' + ) + ;| + solaris*) + args+=( + '(-a -b -d -H -l -m -p -r -s -t -T)-n+[specify number of users to list per line]:number' + ) + ;; +esac + +_arguments -s -S ':file:_files' $args |