1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-03 10:21:46 +02:00

53325: cover newer BSD releases in completion

This commit is contained in:
Oliver Kiddle 2025-01-27 23:00:17 +01:00
parent db01c79cf8
commit 87aba4d437
23 changed files with 182 additions and 60 deletions

View file

@ -1,3 +1,18 @@
2025-01-27 Oliver Kiddle <opk@zsh.org>
* 53325: Completion/BSD/Command/_acpiconf,
Completion/BSD/Command/_bsdconfig, Completion/BSD/Command/_pkgin,
Completion/BSD/Command/_procstat, Completion/BSD/Command/_sockstat,
Completion/BSD/Command/_systat, Completion/Unix/Command/_date,
Completion/Unix/Command/_df, Completion/Unix/Command/_dhclient,
Completion/Unix/Command/_dmidecode, Completion/Unix/Command/_env,
Completion/Unix/Command/_iostat, Completion/Unix/Command/_last,
Completion/Unix/Command/_ls, Completion/Unix/Command/_mv,
Completion/Unix/Command/_ps, Completion/Unix/Command/_script,
Completion/Unix/Command/_sed, Completion/Unix/Command/_vmstat,
Completion/Unix/Command/_w, Completion/Unix/Command/_wc,
Completion/Unix/Command/_zfs: cover newer BSD releases in completion
2025-01-20 Bart Schaefer <schaefer@zsh.org>
* Julian Prein: 53309: Completion/Unix/Command/_uniq: remove

View file

@ -0,0 +1,28 @@
#compdef acpiconf
local curcontext="$curcontext" sep ret=1
local -a state line modes desc
local -A opt_args
_arguments -s \
'(-)-h[display usage information]' \
'(-)-i[get battery information]:battery' \
'(-)-k[ack or abort a pending suspend]:ack' \
'(-)-s[enter specified sleep mode]: :->modes' && ret=0
if [[ -n $state ]]; then
modes=( $(_call_program modes sysctl -n hw.acpi.supported_sleep_state) )
zstyle -s ":completion:${curcontext}:modes" list-separator sep || sep=--
(( $#modes )) || modes=( S3 S4 )
desc=(
"S1 $sep stop the processor clock"
"S2 $sep low wake latency sleep state"
"S3 $sep suspend to RAM"
"S4 $sep suspend to disk"
"S5 $sep soft off state"
)
desc=( ${(M)desc:#(${(~j.|.)modes}) *} )
_wanted modes expl 'mode' compadd -M 'B:S=' -ld desc - ${modes#S} && ret=0
fi
return ret

View file

@ -51,6 +51,7 @@ shortcuts=(
vt_saver
vt_screenmap
vt_ttys
wifi wireless wlan
)
_arguments -s -w -A '-*' : \

View file

@ -5,6 +5,8 @@ local -a state state_descr line expl cmds short pkgs
local -A opt_args
_arguments -s -S -C \
'(-6)-4[only use IPv4 addresses]' \
'(-4)-6[only use IPv6 addresses]' \
'-c+[enable chrooting pkgin in the given repository]:chroot path:_directories' \
'-d[download only]' \
'-f[force database update]' \

View file

@ -1,26 +1,27 @@
#compdef procstat
_arguments -s -A "-*" -S \
'-b[show binary information]' \
'-c[show command line arguments]' \
'-e[show environment variables]' \
'-f[show file descriptor information]' \
'-i[show signal pending and disposition]' \
'-j[show signal pending and blocked information for process threads]' \
'-k[show stacks of kernel threads]' \
'-l[show resource limits]' \
"-L[show LWP info for the process pertaining to it's signal driven exit]" \
'-r[show resource usage]' \
'-s[show security credential information]' \
'-S[show cpuset information]' \
'-t[show thread information]' \
'-v[show virtual memory mappings]' \
'-x[show ELF auxiliary vector]' \
'(1)-b[show binary information]' \
'(1)-c[show command line arguments]' \
'(1)-e[show environment variables]' \
'(1)-f[show file descriptor information]' \
'(1)-i[show signal pending and disposition]' \
'(1)-j[show signal pending and blocked information for process threads]' \
'(1)-k[show stacks of kernel threads]' \
'(1)-l[show resource limits]' \
"(1)-L[show LWP info for the process pertaining to it's signal driven exit]" \
'(1)-r[show resource usage]' \
'(1)-s[show security credential information]' \
'(1)-S[show cpuset information]' \
'(1)-t[show thread information]' \
'(1)-v[show virtual memory mappings]' \
'(1)-x[show ELF auxiliary vector]' \
'-h[suppress table headers]' \
'(1)-a[all processes]' \
'(2 *)-a[all processes]' \
'-w+[repeat information after specified interval]:delay (seconds)' \
'-C[print additional capability information for file descriptors]' \
'-H[statistics per-thread rather than per-process]' \
'-n[numeric form for signals]' \
'1::core file:_path_files -g "*core*(-.)"' \
'1::command:(advlock argument auxv basic binary cpuset credential environment fd file kstack pargs ptlwpinfo pwdx rlimit rlimitusage rusage sigfastblock signal thread tsignal vm)' \
'2::core file:_path_files -g "*core*(-.)"' \
'*:process id:_pids'

View file

@ -29,6 +29,11 @@ case $OSTYPE in
'-q[quiet mode, do not print the header line]'
)
;|
freebsd<14->.*)
args+=(
'-I[show local address of socket to which the current socket is spliced]'
)
;|
freebsd*)
for proto in ${${(M)${(f)"$(</etc/protocols)"}##[a-z0-9]*}}; do
case $proto in

View file

@ -79,6 +79,7 @@ case $OSTYPE in
"-n[don't resolve IP addresses]"
'(-b)-w[refresh interval]:refresh interval'
"(-b)-t[specify amount of refreshes for each screen in 'all' display mode]:turns"
'-z[display 0 instead of space when there is no data]'
)
esac

View file

@ -37,7 +37,10 @@ else
)
;|
freebsd*|dragonfly*|darwin*|netbsd*)
args+=( '-n[only set time on current machine]' )
args+=(
'-n[only set time on current machine]'
'-R[display in RFC2822 format]'
)
;|
freebsd*|dragonfly*|darwin*|openbsd*)
args+=(
@ -61,11 +64,14 @@ else
;|
freebsd*|dragonfly*|darwin*)
args+=(
'-R[display in RFC2822 format]'
'(-R)-I-[display in ISO 8601 format]::precision [date]:(date hours minutes seconds)'
"*-v+[adjust and print (but don't set) date]:[+-]value[ymwdHMS]"
)
;|
dragonfly*|darwin*)
args+=(
'(-R)-I-[display in ISO 8601 format]::precision [date]:(date hours minutes seconds)'
)
;|
freebsd<-12>.*)
args+=(
'-d+:daylight saving time value'
@ -77,6 +83,11 @@ else
freebsd<14->.*|openbsd*)
args+=( '-z+[specify timezone for output]:time zone:_time_zone')
;|
freebsd*)
args+=(
'(-R)-I-[display in ISO 8601 format]::precision [date]:(date hours minutes seconds ns)'
)
;|
netbsd*)
args+=( '-d[output date specified by string]:time string:' )
;;

View file

@ -45,21 +45,25 @@ elif [[ "$OSTYPE" == (darwin|dragonfly|freebsd|netbsd*|openbsd)* ]]; then
'-a[show all mount points]'
'(-b -g -H -h -k -m --si)-g[use 1024^3-byte blocks]'
'(-b -g -H -h -k -m --si)-m[use 1024*1024-byte blocks]'
)
;|
(darwin*|dragonfly*|freebsd*)
args+=(
'(-b -g -H -h -k -m --si)-b[use 512-byte blocks (default)]'
'(-b -g -H -h -k -m --si)-H[human-readable output (base 10)]'
)
;|
(darwin*|freebsd*)
(darwin*|freebsd*|netbsd*)
args+=(
'-c[display a grand total]'
)
;|
(darwin*|freebsd*)
args+=(
'--libxo[generate output via libxo]'
'-,[separate thousands]'
)
;|
(darwin*)
args+=(
'-I[suppress inode counts]'
'-Y[include file system type]'
"-T+$spec"
"!-t+$spec" # obsolete
)
@ -76,14 +80,15 @@ elif [[ "$OSTYPE" == (darwin|dragonfly|freebsd|netbsd*|openbsd)* ]]; then
;|
(freebsd*)
args+=(
'--libxo[generate output via libxo]'
'(-b -g -H -h -k -m --si)--si[human-readable output (base 10)]'
'-,[separate thousands]'
)
;;
(netbsd*)
args+=(
'(-P -G -N)-f[display only the available free]'
'(-G -i -P)-G[display all fields in statvfs]'
'(-G -P)-N[suppress the header line normally output]'
'-W[print widge name instead of the device]'
)
;;
esac

View file

@ -12,6 +12,7 @@ case $OSTYPE in
args+=(
'(-d)-b[immediately move to the background]'
'-l+[specify leases file]:file:_files'
"-n[don't wait for ARP resolution]"
'-p+[specify PID file]:file:_files'
'-u[reject leases with unknown options]'
'-q[quiet]'

View file

@ -5,8 +5,10 @@ _arguments -s \
'(-)'{-h,--help}'[display usage information]' \
'(-q --quiet -u --dump)'{-q,--quiet}'[be less verbose]' \
'--no-quirks[decode everything without quirks]' \
'(-t --type -H --handle -u --dump --dump-bin -s --string)'{-s+,--string=}'[only display value of specified DMI string]:DMI string:(bios-vendor bios-version bios-release-date system-manufacturer system-product-name system-version system-serial-number system-uuid baseboard-manufacturer baseboard-product-name baseboard-version baseboard-serial-number baseboard-asset-tag chassis-manufacturer chassis-type chassis-version chassis-serial-number chassis-asset-tag processor-family processor-manufacturer processor-version processor-frequency)' \
'(-s --string -H --handle --dump-bin)*'{-t+,--type=}'[only display entries of specified type]:entry type:(bios system baseboard chassis processor memory cache connector slot)' \
'(-t --type -H --handle -u --dump --dump-bin -s --string)'{-s+,--string=}'[only display value of specified DMI string]:DMI string:compadd -M "r\:|-=* r\:|=*" - $(_call_program strings dmidecode --list-strings)' \
'--list-strings[list available string keywords]' \
'(-s --string -H --handle --dump-bin)*'{-t+,--type=}'[only display entries of specified type]:entry type:compadd - $(_call_program types dmidecode --list-types)' \
'--list-types[list available type keywords]' \
'(-s --string -t --type -H --handle --dump-bin)'{-H,--handle=}'[only display the entry of specified handle]:handle' \
'(-q --quiet -u --dump -s --string)'{-u,--dump}"[don't decode entries]" \
'(-s --string -t --type -H --handle)--dump-bin=[dump DMI data to a binary file]:file:_files' \

View file

@ -8,6 +8,7 @@ case $variant in
gnu)
(( $#words > 2 )) && ign='!'
args=(
'(-a --argv0)'{-a+,--argv0=}'[pass argument as the zeroth argument of command]:argument'
'(-)'{-i,--ignore-environment}'[start with empty environment]'
'(* -0 --null)'{-0,--null}'[end each output line with NUL, not newline]'
'(--ignore-environment -i --help --version)*'{-u+,--unset=}'[remove variable from the environment]:env var to remove:_parameters -g "*export*"'
@ -28,12 +29,19 @@ case $variant in
'-U[add variables from user and system login.conf(5)]: :->user-class'
)
;|
freebsd*|darwin*)
args=( '-0[use NUL, not newline after each variable in output]' )
freebsd*|netbsd*)
args+=( '-C+[change working directory]:directory:_directories' )
;|
freebsd*|darwin*|netbsd*)
args+=( '-0[use NUL, not newline after each variable in output]' )
;|
freebsd*|darwin*|dragonfly*|netbsd*|openbsd*)
args+=(
'(-i)*-u+[remove variable from the environment]:env var to remove:_parameters -g "*export*"'
)
;|
freebsd*|darwin*|dragonfly*)
args+=(
'(-i)*-u+[remove variable from the environment]:env var to remove:_parameters -g "*export*"'
'-P+[specify alternate executable search PATH]:path:_dir_list'
'-S+[perform word splitting]:string to split'
'*-v[verbose output]'

View file

@ -50,6 +50,9 @@ case $OSTYPE:l in
args+=(
'-x[show extended disk statistics]'
'-y[report data on waiting and active requests]'
'-z[replace drive and CPU statistics that are zero with spaces]'
"-H+[set page height explicitly]:height [$LINES]"
"-W+[set page width explicitly]:width [$COLUMNS]"
)
;;
aix*)

View file

@ -8,17 +8,16 @@ ttys=( ${ttys#/dev/} )
for pattern arg in \
'(solaris*|linux-gnu)' '(--hostlast)-a[display hostname in last column]' \
'((free|net|open)bsd*|darwin*|dragonfly*)' '-h+[limit sessions by hostname]:host:_hosts' \
'((free|open)bsd*)' '-s[report duration in seconds]' \
'(freebsd*|openbsd*)' '-d+[limit sessions to those active at snapshot time]:time ([[CC]YY][MMDD]hhmm[.SS])' \
'((free|open)bsd*|darwin*)' '-s[report duration in seconds]' \
'((free|open)bsd*|darwin*)' '-d+[limit sessions to those active at snapshot time]:time ([[CC]YY][MMDD]hhmm[.SS])' \
'((net|free|open)bsd*|darwin*|dragonfly*)' '-t+[limit sessions by tty]:tty:_ttys -D' \
'openbsd*' '-c[calculate total time]' \
'^darwin*' '(--file)-f+[specify account file]:file:_files' \
'(solaris*|linux-gnu|freebsd*|openbsd*)' '(--limit)-n+[specify number of lines to show]:number' \
'(solaris*|darwin*|linux-gnu|freebsd*|openbsd*)' '(--limit)-n+[specify number of lines to show]:number' \
'((open|net)bsd*|dragonfly*)' '-T[show more detailed time information including year and seconds]' \
'netbsd*' '-x[assume file is in wtmpx(5) format]' \
'netbsd*' '-n[show IP of remote hosts]' \
'freebsd*' '-w[show seconds in duration field]' \
'freebsd*' '-y[show year in session start time]'
'(freebsd*|darwin*)' '-w[show seconds in duration field]' \
'(freebsd*|darwin*)' '-y[show year in session start time]'
do
[[ $OSTYPE = $~pattern ]] && args+=( $arg )
done
@ -58,4 +57,5 @@ else
args+=( '*:user:_users' )
fi
_arguments -s -S $args
_arguments -s -S $args \
'(--file)-f+[specify account file]:file:_files'

View file

@ -61,12 +61,16 @@ if ! _pick_variant gnu=gnu unix --help; then
'(-l -1 -C -m -x)-g[long listing but without owner information]'
)
fi
if [[ $OSTYPE = (netbsd*|darwin*) ]]; then
arguments+=(
"-X[don't cross mount points when recursing]"
)
fi
if [[ $OSTYPE = netbsd* ]]; then
arguments+=(
'-M[output file sizes in comma-separated form]'
'-O[output only leaf (non-directory) files]'
'-P[print full pathname for each file]'
"-X[don't cross mount points when recursing]"
)
fi
if [[ $OSTYPE = (dragonfly*|freebsd*|openbsd*|darwin*) ]]; then

View file

@ -38,11 +38,11 @@ case $variant; in
'(-f -n)-i[prompt before overwriting existing file]'
)
;|
darwin*|dragonfly*|freebsd*|netbsd*)
args+=( "-h[if target is a symlink to a directory, don't follow it]" )
;|
darwin*|dragonfly*|freebsd*)
args+=(
"(-f -i)-n[don't overwrite existing file]"
"-h[if target is a symlink to a directory, don't follow it]"
)
args+=( "(-f -i)-n[don't overwrite existing file]" )
;|
darwin*|dragonfly*|*bsd*)
args+=(

View file

@ -106,9 +106,9 @@ case $OSTYPE in
;|
linux-gnu|netbsd*) bsdarg+=( 'k[specify sort order]' ) ;|
linux-gnu|openbsd*) bsd+=( 'f[show process hierarchy]' ) ;|
darwin*|freebsd*|netbsd*) bsdarg+=( '*G[select processes by real group]' ) ;|
darwin*|freebsd*)
bsd+=( 'X[skip processes with no controlling terminal]' )
bsdarg+=( '*G[select processes by real group]' )
;|
freebsd*|dragonfly*)
bsd+=( 'f[show command and environment for swapped out processes]' )

View file

@ -50,19 +50,28 @@ case $OSTYPE in
'(-d -p -T)-r[record a session with input, output and timing data]'
)
;|
darwin*|netbsd*|freebsd*)
args+=(
'-e[return exit status of the child process]'
)
;|
netbsd*|openbsd*)
args+=(
'-c[run specified command instead of a shell]:command:_cmdstring'
)
;|
darwin*|freebsd*)
args+=(
'(-a -r -k -t)-T[play back a recorded session, reporting only timestamps]: :_date_formats'
)
;|
netbsd*)
args+=( '-f[flush output after each write]' )
;|
freebsd*)
args+=(
'-e[return exit status of the child process]'
'-f[use filemon(4)]'
'(-a -r -k -t)-T[play back a recorded session, reporting only timestamps]: :_date_formats'
'-w[forward terminal size changes on SIGWINCH]'
)
;|
darwin*|dragonfly*|freebsd*)

View file

@ -104,7 +104,7 @@ else
case $OSTYPE in
openbsd*|freebsd*|netbsd*|darwin*|dragonfly*)
args+=(
'(-r -E)'{-E,-r}$extended
'(-r -E -H)'{-E,-r}$extended
'-a[delay opening files listed with w function]'
)
;|
@ -115,8 +115,10 @@ else
args+=(
'-I+[edit files in-place, treating all files as a single input stream]:: :_guard "^(*[@/; \\\]*|?(#c6,)|-*)" "suffix for backup"'
)
;;
;|
openbsd*) args+=( '-u[make output line buffered]' ) ;;
darwin*) args+=( '(-r -E)-H[use enhanced regular expressions]' ) ;;
netbsd*) args+=( '(-r -E)-g[use GNU regular expressions]' '!(-r -E -g)-G' ) ;;
esac
fi

View file

@ -37,10 +37,14 @@ case $OSTYPE in
'-f[report on the number fork syscalls since boot and pages of virtual memory for each]'
)
;|
freebsd*|dragonfly*|netbsd*)
specs+=(
'-n+[change the maximum number of disks to display]:number of disks to display [2]'
)
;|
freebsd*|dragonfly*)
specs+=(
'-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 [2]'
'*-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]'

View file

@ -23,7 +23,7 @@ case $OSTYPE in
openbsd*)
args+=( '-a[translate network addresses into names]' )
;|
(free|net)bsd*|dragonfly*)
(free|net)bsd*|dragonfly*|darwin*)
args+=( '-n[show network addresses as numbers]' )
;|
*bsd*|dragonfly*)
@ -35,6 +35,11 @@ case $OSTYPE in
freebsd*|dragonfly*)
args+=( '-d[dump process list on a per controlling tty basis]' )
;|
netbsd*)
args+=(
'-A[sort tty names alphabetically instead of utmp or utmpx order]'
)
;|
solaris*)
args+=( '!(-s -w -l)'{-l,-w}
'-s[short output form]'

View file

@ -18,7 +18,7 @@ if _pick_variant gnu=GNU unix --version; then
else
args=( -A "-*" "${(@)args:#(|\(*\))(|\*)--*}" )
case $OSTYPE in
freebsd*|netbsd*) args+=( '-L[print longest line lengths]' ) ;;
freebsd*|netbsd*|darwin*) args+=( '-L[print longest line lengths]' ) ;;
openbsd*) args+=( '-h[human readable: use unit suffixes]' ) ;;
solaris*) args+=( ${${(M)args:#*-m\[*}//-m\[/-C\[} ) ;;
esac

View file

@ -79,7 +79,7 @@ rw_ds_props=(
'paths:mountpoint:_directories -W / -P /'"
'multilevel:value:(on off)'
'nbmand:value:(on off)'
'primarycache:value:(all none metadata)'
{prefetch,primarycache}':value:(all none metadata)'
'quota: :->quotas'
'readonly:value:(on off)'
'recordsize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M)'
@ -515,9 +515,11 @@ case $service:$words[1] in
;;
zfs:set)
[[ $implementation = solaris ]] && args=(
'-r[recursively apply value]' \
)
if [[ $implementation = solaris ]]; then
args=( '-r[recursively apply value]' )
else
args=( "-u[update property but don't mount or share dataset]" )
fi
_arguments -C -A "-*" -S $args \
':property:->set-properties' \
'*:filesystem/volume:_zfs_dataset -t fs -t vol'
@ -598,13 +600,14 @@ case $service:$words[1] in
zfs:mount)
[[ $OSTYPE != freebsd* ]] && args=( '-O[overlay mount]' )
[[ $implementation = openzfs ]] && args+=(
'-l[load keys for encrypted filesystems as they are being mounted]'
'-l[load keys for encrypted filesystems as they are being mounted]'
'(-a)-R[mount filesystems along with all their children]'
)
_arguments -A "-*" -S $args \
'-o+[specify temporary file system options]: :_values -s , "option" {,no}{atime,dev,exec,relatime,suid,xattr} ro rw' \
'-v[report mount progress]' \
'-f[force mount]' \
'(:)-a[mount all available ZFS filesystems]' \
'(: -R)-a[mount all available ZFS filesystems]' \
'(-a):filesystem:_zfs_dataset -t fs'
;;
@ -888,6 +891,12 @@ case $service:$words[1] in
':property:($delegatable_perms $ro_ds_props ${rw_ds_props%%:*})'
;;
zpool:(clear|online))
[[ $OSTYPE = linux* ]] && args=(
"--power[power on the device's slot in the storage enclosure]"
)
;|
zpool:help)
_arguments -A "-*" -S \
- commands \
@ -905,6 +914,7 @@ case $service:$words[1] in
'-L[display real paths for vdevs resolving all symbolic links]'
'-o+[set given pool properties]: :_values -s , "property" "${(@M)ci_po_props\:#ashift*}"' \
'-P[display real paths for vdevs instead of only the last component of the path]'
--allow-ashift-mismatch --allow-in-use --allow-replication-mismatch
)
elif [[ $implementation = solaris ]]; then
args=( '-l[display configuration in /dev/chassis location form]' )
@ -1004,7 +1014,7 @@ case $service:$words[1] in
zpool:get)
[[ $implementation = solaris ]] && args=(
'-s+[specify sources to display]: :_values -s "source" local default none'
'-s+[specify sources to display]: :_values -s , "source" local default none'
)
_arguments -A "-*" -S $args \
'-H[suppress headers and tab-delimit fields]' \
@ -1140,6 +1150,9 @@ case $service:$words[1] in
[[ $implementation = openzfs ]] && args=(
'-f[force disk into faulted state]'
)
[[ $OSTYPE = linux* ]] && args=(
"--power[power off the device's slot in the storage enclosure]"
)
_arguments -C -A "-*" -S $args \
'-t[offline until next reboot]' \
':pool:_zfs_pool' \
@ -1147,7 +1160,7 @@ case $service:$words[1] in
;;
zpool:online)
_arguments -C -A "-*" -S \
_arguments -C -A "-*" -S $args \
'-e[expand device to use all available space]' \
':pool:_zfs_pool' \
'*:virtual device:->pool-devices'
@ -1234,8 +1247,10 @@ case $service:$words[1] in
zpool:status)
if [[ $implementation = openzfs ]]; then
args=(
'--power[display vdev enclosure slot power status]'
'-D[display a histogram of deduplication statistics]'
'-c[run scripts on each vdev]:script:_files -W "($ZPOOL_SCRIPTS_PATH /etc/zfs/zpool.d ~/.zpool.d)"'
'-e[only show unhealthy vdevs]'
'-i[display vdev initialization status]'
'-g[display vdev GUIDs instead of the normal device names]'
'-L[display real paths for vdevs resolving all symbolic links]'