Compare commits
41 Commits
6324b074ab
...
a971c76f6d
| Author | SHA1 | Date |
|---|---|---|
|
|
a971c76f6d | |
|
|
46317b36e2 | |
|
|
8cecc84fb3 | |
|
|
508f2971c2 | |
|
|
094a7e79b0 | |
|
|
e4072c73ba | |
|
|
c30c5509e1 | |
|
|
7e671b08d1 | |
|
|
572ed9638f | |
|
|
c16614f37e | |
|
|
10147cfb99 | |
|
|
b664a1e7f3 | |
|
|
48203e84ae | |
|
|
863c0116e1 | |
|
|
7fbdd25526 | |
|
|
55cf78b510 | |
|
|
8433d73097 | |
|
|
97621528c6 | |
|
|
1262853ed3 | |
|
|
5a79f8c721 | |
|
|
59e36ba77b | |
|
|
7f461a9a40 | |
|
|
0b9424d0c8 | |
|
|
5384be72c5 | |
|
|
7c4d643f58 | |
|
|
d1478b05be | |
|
|
a8fcd0402f | |
|
|
5359bbf0e7 | |
|
|
a3e89f7c56 | |
|
|
cf57a3266c | |
|
|
41896a6013 | |
|
|
0d8667bb6a | |
|
|
79c6d1715f | |
|
|
f5e58a5ca7 | |
|
|
6c8cd1b111 | |
|
|
eb711299c5 | |
|
|
d71c3c84cc | |
|
|
c3f1f7748d | |
|
|
45fd6f398a | |
|
|
26b538f012 | |
|
|
fd43209f3a |
|
|
@ -0,0 +1,66 @@
|
||||||
|
#compdef augmatch
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# * Neither the name of the zsh-users nor the
|
||||||
|
# names of its contributors may be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
|
||||||
|
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for augmatch 1.14.1 (https://augeas.net/)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_augmatch_lens() {
|
||||||
|
local lenses=($(augtool --noload 'match /augeas/load/*/lens' | sed -e 's/.*@//'))
|
||||||
|
_values lenses $lenses
|
||||||
|
}
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'(- *)'{-h,--help}'[show help message]' \
|
||||||
|
'(-a --all)'{-a,--all}'[print all tree nodes, even ones without an associated value]' \
|
||||||
|
'(-e --extract)'{-e,--extract}'[only print the parts of the tree that are matched with --match]' \
|
||||||
|
\*{-I,--include=}'[add directory to the module loadpath]:dir:_files -/' \
|
||||||
|
'(-l --lens)'{-l,--lens=}'[use lens for the given file]:lens:_augmatch_lens' \
|
||||||
|
'(-L --print-lens)'{-L,--print-lens}'[print the name of lens]' \
|
||||||
|
'(-m --match)'{-m,--match=}'[only print the parts of the tree that match]:expr' \
|
||||||
|
'(-r --root)'{-r,--root=}'[use directory as the root of the filesystem]:dir:_files -/' \
|
||||||
|
'(-S --nostdinc)'{-S,--nostdinc}'[do not search any of the default directories for lenses]' \
|
||||||
|
'(-o --only-value)'{-o,--only-value}'[print only the value and not label or the path of nodes]' \
|
||||||
|
'(-q --quiet)'{-q,--quiet}'[do not print anything]' \
|
||||||
|
'*:: :_files'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
#compdef augparse
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# * Neither the name of the zsh-users nor the
|
||||||
|
# names of its contributors may be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
|
||||||
|
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for augparse 1.14.1 (https://augeas.net/)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'(- *)'{-h,--help}'[show help message]' \
|
||||||
|
'(- *)--version[print version information and exit]' \
|
||||||
|
\*{-I,--include=}'[add directory to the module loadpath]:dir:_files -/' \
|
||||||
|
'(-t --trace)'{-t,--trace}'[print a trace of modules that are being loaded]' \
|
||||||
|
'--nostdinc[do not search any of the default directories for modules]' \
|
||||||
|
'--notypecheck[do not perform lens type checks]' \
|
||||||
|
'*:: :_files'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
#compdef augprint
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# * Neither the name of the zsh-users nor the
|
||||||
|
# names of its contributors may be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
|
||||||
|
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for augprint 1.14.1 (https://augeas.net/)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_augprint_lens() {
|
||||||
|
local lenses=($(augtool --noload 'match /augeas/load/*/lens' | sed -e 's/.*@//'))
|
||||||
|
_values lenses $lenses
|
||||||
|
}
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'(- *)'{-h,--help}'[show help message]' \
|
||||||
|
'(-v --verbose)'{-v,--verbose}'[include the original numbered paths as comments in the output]' \
|
||||||
|
'(-r --regexp)'{-r-,--regexp=-}'[generate regular expressions to match values]:num' \
|
||||||
|
'(-l --lens)'{-l,--lens=}'[use lens for the given file]:lens:_augprint_lens' \
|
||||||
|
'(-t --target)'{-t,--target=}'[generate the script as if its path was really targetfile]:file:_files' \
|
||||||
|
'(-s --noseq)'{-s,--noseq}'[do not use "seq::*" in the output]' \
|
||||||
|
'*:: :_files'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
10
src/_cap
10
src/_cap
|
|
@ -28,7 +28,7 @@
|
||||||
# Description
|
# Description
|
||||||
# -----------
|
# -----------
|
||||||
#
|
#
|
||||||
# Completion script for Capistrano 3.17.1 (https://capistranorb.com/)
|
# Completion script for Capistrano 3.19.2 (https://capistranorb.com/)
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Authors
|
# Authors
|
||||||
|
|
@ -46,22 +46,24 @@ _arguments -C \
|
||||||
'--backtrace=[Enable full backtrace]: :(stderr stdout)' \
|
'--backtrace=[Enable full backtrace]: :(stderr stdout)' \
|
||||||
'--comments[Show commented tasks only]' \
|
'--comments[Show commented tasks only]' \
|
||||||
'--job-stats[Display job statistics]:level' \
|
'--job-stats[Display job statistics]:level' \
|
||||||
|
'--rules[Trace the rules resolution]' \
|
||||||
'--suppress-backtrace[Suppress backtrace lines matching regexp PATTERN]:pattern' \
|
'--suppress-backtrace[Suppress backtrace lines matching regexp PATTERN]:pattern' \
|
||||||
'(-A --all)'{-A,--all}'[Show all tasks, even uncommented ones]' \
|
'(-A --all)'{-A,--all}'[Show all tasks, even uncommented ones]' \
|
||||||
'(-B --build-all)'{-B,--build-all}'[Build all prerequisites, including those which are up-to-date]' \
|
'(-B --build-all)'{-B,--build-all}'[Build all prerequisites, including those which are up-to-date]' \
|
||||||
'(-C --directory)'{-C,--directory}'[Change to DIRECTORY before doing anything]: :_files -/' \
|
'(-C --directory)'{-C,--directory}'[Change to DIRECTORY before doing anything]: :_files -/' \
|
||||||
'(-D --describe)'{-D,--describe}'[Describe the tasks, then exit]:pattern' \
|
'(-D --describe)'{-D,--describe}'[Describe the tasks, then exit]:pattern' \
|
||||||
'(-E --execute-continue)'{-E,--execute-continue}'[Execute Ruby code and exit]:code' \
|
'(-e --execute)'{-e,--execute}'[Execute some Ruby code and exit]:code' \
|
||||||
|
'(-E --execute-continue)'{-E,--execute-continue}'[Execute Ruby code and continue with task processing]:code' \
|
||||||
'(-f --rakefile)'{-f,--rakefile}'[Use FILENAME as the rakefile to search for]: :_files' \
|
'(-f --rakefile)'{-f,--rakefile}'[Use FILENAME as the rakefile to search for]: :_files' \
|
||||||
'(-G --no-system --nosystem)'{-G,--no-system,--nosystem}'[Use standard project Rakefile search paths, ignore system wide rakefiles]' \
|
'(-G --no-system --nosystem)'{-G,--no-system,--nosystem}'[Use standard project Rakefile search paths, ignore system wide rakefiles]' \
|
||||||
'(-g --system)'{-g,--system}'[Using system wide rakefiles]' \
|
'(-g --system)'{-g,--system}'[Using system wide rakefiles]' \
|
||||||
'(-I --libdir)'\*{-I,--libdir}'[Include LIBDIR in the search path for required modules]: :_files -/' \
|
'(-I --libdir)'\*{-I,--libdir}'[Include LIBDIR in the search path for required modules]: :_files -/' \
|
||||||
'(-j --jobs)'{-j,--jobs}'[Specifies the maximum number of tasks to execute in parallel]:num' \
|
'(-j --jobs)'{-j-,--jobs-}'[Specifies the maximum number of tasks to execute in parallel]:num' \
|
||||||
'(-m --multitask)'{-m,--multitask}'[Treat all tasks as multitasks]' \
|
'(-m --multitask)'{-m,--multitask}'[Treat all tasks as multitasks]' \
|
||||||
'(-N --no-search --nosearch)'{-N,--no-search,--nosearch}'[Do not search parent directories for the Rakefile]' \
|
'(-N --no-search --nosearch)'{-N,--no-search,--nosearch}'[Do not search parent directories for the Rakefile]' \
|
||||||
'(-P --prereqs)'{-P,--prereqs}'[Display the tasks and dependencies, then exit]' \
|
'(-P --prereqs)'{-P,--prereqs}'[Display the tasks and dependencies, then exit]' \
|
||||||
'--execute-print[Execute some Ruby code, print the result, then exit]:code' \
|
'--execute-print[Execute some Ruby code, print the result, then exit]:code' \
|
||||||
'--require[Require MODULE before executing rakefile]:module' \
|
'*--require[Require MODULE before executing rakefile]:module' \
|
||||||
'(-R --rakelibdir --rakelib)'{-R,--rakelibdir,--rakelib}'[Auto-import any .rake files in RAKELIBDIR]: :_files -/' \
|
'(-R --rakelibdir --rakelib)'{-R,--rakelibdir,--rakelib}'[Auto-import any .rake files in RAKELIBDIR]: :_files -/' \
|
||||||
'(-t --trace)'{-t,--trace}'[Turn on invoke/execute tracing, enable full backtrace]: :(stderr stdout)' \
|
'(-t --trace)'{-t,--trace}'[Turn on invoke/execute tracing, enable full backtrace]: :(stderr stdout)' \
|
||||||
'(-T --tasks)'{-T,--tasks}'[Display the tasks with descriptions]::pattern' \
|
'(-T --tasks)'{-T,--tasks}'[Display the tasks with descriptions]::pattern' \
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,262 @@
|
||||||
|
#compdef certbot
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for certbot 5.1.0 (https://github.com/certbot/certbot)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_certbot() {
|
||||||
|
typeset -A opt_args
|
||||||
|
local context state line
|
||||||
|
local curcontext="$curcontext"
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
_arguments -C -A "-*" \
|
||||||
|
'(- *)'{-h,--help}'[Print help message]:topic:_certbot_help_topics' \
|
||||||
|
'(- *)--version[Print version and exit]' \
|
||||||
|
'1: :_certbot_subcommands' \
|
||||||
|
'*::arg:->args' \
|
||||||
|
&& ret=0
|
||||||
|
|
||||||
|
case "$state" in
|
||||||
|
(args)
|
||||||
|
local -a opts=(
|
||||||
|
'(- *)'{-h,--help}'[Show help message and exit]'
|
||||||
|
'(-c --config)'{-c,--config}'[Path to config file]:config_file:_files'
|
||||||
|
)
|
||||||
|
case $words[1] in
|
||||||
|
(run|certonly|renew|enhance|certificates|delete|reconfigure)
|
||||||
|
opts+=(
|
||||||
|
'--cert-name[Certificate name to apply]:name'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(run|certonly|renew|reconfigure)
|
||||||
|
opts+=(
|
||||||
|
'--deploy-hook[Command to be run once for each successfully issued certificate]:hook'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(run|certonly|renew)
|
||||||
|
opts+=(
|
||||||
|
'(-q --quiet)'{-q,--quiet}'[Silence all output except errors]'
|
||||||
|
'--required-profile[Request the given profile name from the ACME server]:profile'
|
||||||
|
'--preferred-profile[Request the given profile name from the ACME server]:profile'
|
||||||
|
'--preferred-chain[Set the preferred certificate chain]:chain'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(run|certonly|enhance|certificates)
|
||||||
|
opts+=(
|
||||||
|
'(-d --domains --domain)'{-d,--domains,--domain}'[Domain names to include]'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(run|certonly|enhance|register)
|
||||||
|
opts+=(
|
||||||
|
'--force-interactive[Force Certbot to be interactive even not in a terminal]'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(run|certonly|enhance)
|
||||||
|
opts+=(
|
||||||
|
'(-n --non-interactive --noninteractive)'{-n,--non-interactive,--noninteractive}'[Run without ever asking for user input]'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(run|certonly|register)
|
||||||
|
opts+=(
|
||||||
|
'--eab-kid[Key identifier for External Account Binding]:eab_kid'
|
||||||
|
'--eab-hmac-key[HMAC key for External Account Binding]:eab_hmac_key'
|
||||||
|
'--eab-hmac-alg[HMAC algorithm for External Account Binding(default: HS256)]:algorithm:(HS256 HS384 HS512)'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(run|certonly)
|
||||||
|
opts+=(
|
||||||
|
'(--keep-until-expiring --keep --reinstall)'{--keep-until-expiring,--keep,--reinstall}'[Always keep the existing one until it is due for renewal]'
|
||||||
|
|
||||||
|
'--debug-challenges[After setting up challenges, wait for user input before submitting to CA]'
|
||||||
|
|
||||||
|
'--issuance-timeout[How many seconds Certbot will wait for the server to issue a certificate]:seconds'
|
||||||
|
'--apache[Obtain and install certificates using Apache]'
|
||||||
|
'--nginx[Obtain and install certificates using Nginx]'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(certonly|renew|reconfigure)
|
||||||
|
opts+=(
|
||||||
|
'--run-deploy-hooks[run any applicable deploy hooks]'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(certonly|renew)
|
||||||
|
opts+=(
|
||||||
|
"--dry-run[Perform a test run against the Let's Encrypt staging server]"
|
||||||
|
'--allow-subset-of-names[When performing domain validation, do not consider it a failure]'
|
||||||
|
'--preferred-challenges[A sorted, comma delimited list of the preferred challenge]:challenges'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(run|revoke)
|
||||||
|
opts+=(
|
||||||
|
'(--test-cert --staging)'{--test-cert,--staging}"[Use the Let's Encrypt staging server to obtain or revoke test]"
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(certonly|revoke)
|
||||||
|
opts+=(
|
||||||
|
'--cert-path[Path to where certificate is saved]:cert:_files'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(certonly|reconfigure)
|
||||||
|
opts+=(
|
||||||
|
'--webroot[Obtain certificates by placing files in a webroot directory]'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(certonly)
|
||||||
|
opts+=(
|
||||||
|
'--csr[Path to a Certificate Signing Request (CSR) in DER or PEM format]:csr:_files'
|
||||||
|
'--standalone[Obtain certificates using a "standalone" webserver]'
|
||||||
|
'--manual[Provide laborious manual instructions for obtaining a certificate]'
|
||||||
|
'--dns-cloudflare[Obtain certificates using a Cloudflare DNS TXT record]'
|
||||||
|
'--dns-digitalocean[Obtain certificates using a DigitalOcean DNS TXT record]'
|
||||||
|
'--dns-dnsimple[Obtain certificates using a DNSimple DNS TXT record]'
|
||||||
|
'--dns-dnsmadeeasy[Obtain certificates using a DNS Made Easy DNS TXT record]'
|
||||||
|
'--dns-gehirn[Obtain certificates using a Gehirn DNS TXT record]'
|
||||||
|
'--dns-google[Obtain certificates using a Google Cloud DNS TXT record]'
|
||||||
|
'--dns-linode[Obtain certificates using a Linode DNS TXT record]'
|
||||||
|
'--dns-luadns[Obtain certificates using a LuaDNS DNS TXT record]'
|
||||||
|
'--dns-nsone[Obtain certificates using a NS1 DNS TXT record]'
|
||||||
|
'--dns-ovh[Obtain certificates using a OVH DNS TXT record]'
|
||||||
|
'--dns-rfc2136[Obtain certificates using a BIND DNS TXT record]'
|
||||||
|
'--dns-route53[Obtain certificates using a Route53 DNS TXT record]'
|
||||||
|
'--dns-sakuracloud[Obtain certificates using a Sakura Cloud DNS TXT record]'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(renew|reconfigure)
|
||||||
|
opts+=(
|
||||||
|
'--pre-hook[Command to be run before obtaining any certificates]:pre_hook'
|
||||||
|
'--post-hook[Command to be run after attempting to obtain/renew certificates]:post_hook'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(renew)
|
||||||
|
opts+=(
|
||||||
|
'(--force-renewal --renew-by-default)'{--force-renewal,--renew-by-default}'[renew now regardless of whether it is near expiry]'
|
||||||
|
'--disable-hook-validation[Disable command validation for hook commands]'
|
||||||
|
"--no-directory-hooks[Disable running executables found in Certbot's hook directories]"
|
||||||
|
'--disable-renew-updates[Disable automatic updates to your server configuration]'
|
||||||
|
'--no-autorenew[Disable auto renewal of certificates]'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(enhance)
|
||||||
|
opts+=(
|
||||||
|
'--redirect[Automatically redirect all HTTP traffic to HTTPS]'
|
||||||
|
'--hsts[Add Strict-Transport-Security header to every HTTP response]'
|
||||||
|
'--uir[Add "Content-Security-Policy: upgrade-insecure-requests" header to every HTTP response]'
|
||||||
|
'--auto-hsts[Gradually increasing max-age value for HTTP Strict Transport Security security header]'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(revoke)
|
||||||
|
opts+=(
|
||||||
|
'--reason[Specify reason for revoking certificates]:reason:(unspecified keycompromise affiliationchanged superseded cessationofoperation)'
|
||||||
|
'(--delete-after-revoke --no-delete-after-revoke)--delete-after-revoke[Delete certificates after revoking them]'
|
||||||
|
'(--delete-after-revoke --no-delete-after-revoke)--no-delete-after-revoke[Do not delete certificates after revoking them]'
|
||||||
|
'--key-path[Path to private key for certificates instructions or revocation]:key_path:_files'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(reconfigure)
|
||||||
|
opts+=(
|
||||||
|
'(-a --authenticator)'{-a,--authenticator}'[Authenticator plugin name]:plugin'
|
||||||
|
'(-i --installer)'{-i,--installer}'[Installer plugin name]:plugin'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(register|unregister|update_account)
|
||||||
|
opts+=(
|
||||||
|
'(-m --email)'{-m,--email}'[Email used for registration and recovery contact]:email')
|
||||||
|
;|
|
||||||
|
(register|update_account)
|
||||||
|
opts+=(
|
||||||
|
'(--eff-email --no-eff-email)--eff-email[Share your e-mail address with EFF]'
|
||||||
|
'(--eff-email --no-eff-email)--no-eff-email[Do not share your email address with EFF]'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(unregister)
|
||||||
|
opts+=(
|
||||||
|
'--account[Account ID to use]:account_id'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
(show_account)
|
||||||
|
opts+=(
|
||||||
|
'--server[ACME Directory Resource URI]:server'
|
||||||
|
)
|
||||||
|
;|
|
||||||
|
esac
|
||||||
|
|
||||||
|
_arguments "$opts[@]" && ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_certbot_subcommands] )) ||
|
||||||
|
_certbot_subcommands() {
|
||||||
|
local -a commands=(
|
||||||
|
"run:Obtain & install a certificate in your current webserver"
|
||||||
|
"certonly:Obtain or renew a certificate, but do not install it"
|
||||||
|
"renew:Renew all previously obtained certificates that are near"
|
||||||
|
"enhance:Add security enhancements to your existing configuration"
|
||||||
|
"certificates:Display information about certificates you have from Certbot"
|
||||||
|
"revoke:Revoke a certificate (supply --cert-name or --cert-path)"
|
||||||
|
"delete:Delete a certificate (supply --cert-name)"
|
||||||
|
"reconfigure:Update a certificate's configuration (supply --cert-name)"
|
||||||
|
"register:Create an ACME account"
|
||||||
|
"unregister:Deactivate an ACME account"
|
||||||
|
"update_account:Update an ACME account"
|
||||||
|
"show_account:Display account details"
|
||||||
|
)
|
||||||
|
_describe -t commands 'command' commands "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_certbot_help_topics] )) ||
|
||||||
|
_certbot_help_topics() {
|
||||||
|
local -a topics=(
|
||||||
|
# topics
|
||||||
|
all automation commands paths security testing
|
||||||
|
# subcommands
|
||||||
|
run certonly renew enhance certificates revoke delete reconfigure register unregister
|
||||||
|
update_account show_account
|
||||||
|
# plugins
|
||||||
|
nginx apache standalone webroot
|
||||||
|
)
|
||||||
|
_values topics $topics
|
||||||
|
}
|
||||||
|
|
||||||
|
_certbot "$@"
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
#compdef chcpu
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for chcpu v2.41 (https://github.com/util-linux/util-linux)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'(- *)'{-h,--help}'[display this help]' \
|
||||||
|
'(- *)'{-V,--version}'[display version]' \
|
||||||
|
'(-c --configure)'{-c,--configure}'[configure the specified CPUs]:cpu_list' \
|
||||||
|
'(-d --disable)'{-d,--disable}'[disable the specified CPUs]:cpu_list' \
|
||||||
|
'(-e --enable)'{-e,--enable}'[enable the specified CPUs]:cpu_list' \
|
||||||
|
'(-g --deconfigure)'{-d,--deconfigure}'[deconfigure the specified CPUs]:cpu_list' \
|
||||||
|
'(-p --dispatch)'{-p,--dispatch}'[set the CPU dispatching mode]:mode:(horizontal vertical)' \
|
||||||
|
'(-r --rescan)'{-r,--rescan}'[trigger a rescan of CPUs]'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
#compdef chpasswd
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for chpasswd v4.17 (https://github.com/shadow-maint/shadow)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'(- *)'{-h,--help}'[display this help]' \
|
||||||
|
'(-c --crypt-method)'{-c,--crypt-method}'[use the specified method to encrypt the passwords]:method:(DES MD5 SHA256 SHA512 YESCRYPT NONE)' \
|
||||||
|
'(-e --encrypted)'{-e,--encrypted}'[supplied passwords are in encrypted form]' \
|
||||||
|
'(-m --md5)'{-m,--md5}'[use MD5 encryption instead of DES]' \
|
||||||
|
'(-R --root)'{-R,--root}'[apply changes in the specified CHROOT_DIR directory]:dir:_files -/' \
|
||||||
|
'(-P --prefix)'{-P,--prefix}'[apply changes to configuration files under the specified directory PREFIX_DIR]:dir:_files -/' \
|
||||||
|
'(-s --sha-rounds)'{-s,--sha-rounds}'[use the specified number of rounds to encrypt the passwords]:rounds'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -0,0 +1,634 @@
|
||||||
|
#compdef diskutil
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for diskutil command macOS 26
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_diskutil() {
|
||||||
|
typeset -A opt_args
|
||||||
|
local context state line
|
||||||
|
local curcontext="$curcontext"
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'1: :_diskutil_subcommands' \
|
||||||
|
'*::arg:->args' \
|
||||||
|
&& ret=0
|
||||||
|
|
||||||
|
case "$state" in
|
||||||
|
(args)
|
||||||
|
case $words[1] in
|
||||||
|
(list)
|
||||||
|
_arguments \
|
||||||
|
'-plist[output plist instead of normal user-readable output]' \
|
||||||
|
'1:: :(internal external)' \
|
||||||
|
'2:: :(physical virtual)' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(info)
|
||||||
|
_arguments \
|
||||||
|
'-plist[output plist instead of normal user-readable output]' \
|
||||||
|
'-all[output all disks]' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(listFilesystems)
|
||||||
|
_arguments \
|
||||||
|
'-plist[output plist instead of normal user-readable output]' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(unmount|unmountDisk|eject|disableJournal|disableJournal)
|
||||||
|
_alternative 'force: :(force)' 'device: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(mount)
|
||||||
|
_arguments \
|
||||||
|
'-mountOptions[mount options]:option' \
|
||||||
|
'-mountPoint[mount point]:path:_files -/' \
|
||||||
|
'*:: :_diskutil_mount_args' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(moveJournal)
|
||||||
|
_alternative 'internal: :(internal)' 'device: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(eraseDisk)
|
||||||
|
_arguments \
|
||||||
|
'-noEFI[do not create EFI partition]' \
|
||||||
|
'1:format:_diskutil_file_systems' \
|
||||||
|
'2:name' \
|
||||||
|
'*:: :_diskutil_erasedisk_args' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(eraseVolume)
|
||||||
|
_arguments \
|
||||||
|
'1:format:_diskutil_file_systems' \
|
||||||
|
'2:name' \
|
||||||
|
'*:: :_diskutil_erasedisk_args' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(zeroDisk)
|
||||||
|
_alternative 'force: :(force)' 'short: :(short)' 'device: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(secureErase)
|
||||||
|
_arguments \
|
||||||
|
'1:format:_diskutil_secure_erase_args' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(partitionDisk)
|
||||||
|
_arguments \
|
||||||
|
'-noEFI[do not create EFI partition on the target disk]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(resizeVolume)
|
||||||
|
_arguments \
|
||||||
|
'-plist[emit a property list instead of user-formatted output]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(APFS)
|
||||||
|
_diskutil_APFS && ret=0
|
||||||
|
;;
|
||||||
|
(appleRAID)
|
||||||
|
_diskutil_appleRAID && ret=0
|
||||||
|
;;
|
||||||
|
(coreStorage)
|
||||||
|
_diskutil_corestorage && ret=0
|
||||||
|
;;
|
||||||
|
(image)
|
||||||
|
_diskutil_image && ret=0
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
_arguments \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_subcommands] )) ||
|
||||||
|
_diskutil_subcommands() {
|
||||||
|
local -a commands=(
|
||||||
|
"list:List disks"
|
||||||
|
"info:Get detailed information about a specific whole disk or partition"
|
||||||
|
"activity:Continuously display system-wide disk manipulation activity"
|
||||||
|
"listFilesystems:Show the file system personalities available for formatting"
|
||||||
|
"unmount:Unmount a single volume"
|
||||||
|
"unmountDisk:Given a disk containing a partition map, unmount all of its volumes"
|
||||||
|
"eject:Eject a disk"
|
||||||
|
"mount:Mount a single volume"
|
||||||
|
"mountDisk:Mount all mountable and UI-browsable volumes on the give partition map"
|
||||||
|
"rename:Rename a volume"
|
||||||
|
"enableJournal:Enable journaling on an HFS+ volume"
|
||||||
|
"disableJournal:Disable journaling on an HFS+ volume"
|
||||||
|
"moveJournal:Create a 512MB Apple_Journal partiton"
|
||||||
|
"enableOwnership:Enable ownership a volume"
|
||||||
|
"disableOwnership:Disable ownership of a volume"
|
||||||
|
"verifyVolume:Verify the file system data structures of a volume"
|
||||||
|
"repairVolume:Repair the file system data structures of a volume"
|
||||||
|
"verifyDisk:Verify the partition map layout of a whole disk intended for booting or data use"
|
||||||
|
"repairDisk:Repair the partition map layout of a whole disk intended for booting or data use"
|
||||||
|
"eraseDisk:Erase an existing disk"
|
||||||
|
"eraseVolume:Write out a new empty file system volume"
|
||||||
|
"reformat:Erase an existing volume by writing out a new empty file system"
|
||||||
|
"eraseOptical:Erase optical media"
|
||||||
|
"zeroDisk:Erase a device, writing zeros to the media"
|
||||||
|
"randomDisk:Erase a whole disk, writing random data to the media"
|
||||||
|
"secureErase:Erase, using a secure method"
|
||||||
|
"partitionDisk:Partition a disk, removing all volumes"
|
||||||
|
"resizeVolume:Non-destructively resize a volume"
|
||||||
|
"splitPartition:Destructively split a volume into multiple partitions"
|
||||||
|
"mergePartitions:Merge two or more partitions on a disk"
|
||||||
|
"addPartition:Create a new partition following an existing partition"
|
||||||
|
"APFS:Apple APFS is a system of virtual volumes"
|
||||||
|
"appleRAID:create, manipulate, destroy AppleRAID volumes"
|
||||||
|
"coreStorage:gather information/remove CoreStorage volumes"
|
||||||
|
"image:manipulate DiskImages framework with StorageKit framework"
|
||||||
|
)
|
||||||
|
_describe -t commands 'command' commands "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_mount_args] )) ||
|
||||||
|
_diskutil_mount_args() {
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
local -a attributes=(
|
||||||
|
'readonly[the file system is mounted read only]'
|
||||||
|
'nobrowse[the file system is mounted with a recommendation to prevent display]'
|
||||||
|
)
|
||||||
|
|
||||||
|
_alternative \
|
||||||
|
'attributes: :_values -w attributes $attributes' \
|
||||||
|
'device: :_files' && ret=0
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_erasedisk_args] )) ||
|
||||||
|
_diskutil_erasedisk_args() {
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
_alternative \
|
||||||
|
'type: :(APM MBR GPT)' \
|
||||||
|
'device: :_files' && ret=0
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_secure_erase_args] )) ||
|
||||||
|
_diskutil_secure_erase_args() {
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
local -a levels=(
|
||||||
|
'0[Single-pass zero fill erase]'
|
||||||
|
'1[Single-pass random fill erase]'
|
||||||
|
'2[Seven-pass erase]'
|
||||||
|
'3[Gutmann algorithm 35-pass erase]'
|
||||||
|
'4[Three-pass erase, consisting of two random fills plus a final zero fill]'
|
||||||
|
)
|
||||||
|
|
||||||
|
_alternative \
|
||||||
|
'freespace: :(freespace)' \
|
||||||
|
'level: :_values level $levels' && ret=0
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_file_systems] )) ||
|
||||||
|
_diskutil_file_systems() {
|
||||||
|
local file_systems=(
|
||||||
|
'APFSX:Case-sensitive APFS'
|
||||||
|
'APFS:APFS'
|
||||||
|
'ExFAT:ExFat'
|
||||||
|
'FREE:Free Space'
|
||||||
|
'MS-DOS:FAT'
|
||||||
|
'FAT32:FAT32'
|
||||||
|
'HFS+:MacOS Extended HFS+'
|
||||||
|
'HFSX:Case-sensitive Mac OS Extended HFS+'
|
||||||
|
'JHFSX:Case-sensitive and journaled Mac OS Extended HFS+'
|
||||||
|
'JHFS+:Journaled Mac OS Extended HFS+'
|
||||||
|
)
|
||||||
|
|
||||||
|
_describe -t file_systems 'file_system' file_systems "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_APFS] )) ||
|
||||||
|
_diskutil_APFS() {
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
'1: :_diskutil_APFS_subcommands' \
|
||||||
|
'*:: :->arg' \
|
||||||
|
&& ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
(arg)
|
||||||
|
case $words[1] in
|
||||||
|
(list|resizeContainer|listCryptoUsers|listSnapshots)
|
||||||
|
_arguments \
|
||||||
|
'-plist[emit a property list instead of user-formatted output]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(convert)
|
||||||
|
_arguments \
|
||||||
|
'-dryrun[all calculations, checks, some data moving is performed but your disk is left as valid HFS]' \
|
||||||
|
'-prebootSource[staging directory of macOS boot items]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(deleteContainer)
|
||||||
|
_arguments \
|
||||||
|
'-force[Activate an alternate last-resort mode]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(addVolume)
|
||||||
|
_arguments \
|
||||||
|
'-passprompt[will be prompted interactively for a passphrase]' \
|
||||||
|
'-passphrase[passphrase]:passphrase' \
|
||||||
|
'-stdinpassphrase[read passphrase from standard input]' \
|
||||||
|
'-passphraseHint[passphrase hint]:hint' \
|
||||||
|
'-reserve[guarantee a minimum amount of space for your volume]:reserve' \
|
||||||
|
"-quota[limit your volume's file usage to a maximum amount]:quota" \
|
||||||
|
'-role[meta-data flags from APFS Volume Roles]:roles' \
|
||||||
|
'-groupWith[become a member of the same APFS Volume Group]' \
|
||||||
|
'-sibling[sibling group device]:group_device' \
|
||||||
|
'-nomount[leave volume unmounted]' \
|
||||||
|
'-mountpoint[mountpoint path]:path:_files' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(eraseVolume)
|
||||||
|
_arguments \
|
||||||
|
'-passprompt[will be prompted interactively for a passphrase]' \
|
||||||
|
'-passphrase[passphrase]:passphrase' \
|
||||||
|
'-stdinpassphrase[read passphrase from standard input]' \
|
||||||
|
'-passphraseHint[passphrase hint]:hint' \
|
||||||
|
'-role[meta-data flags from APFS Volume Roles]:roles' \
|
||||||
|
'-groupWith[become a member of the same APFS Volume Group]' \
|
||||||
|
'-sibling[sibling group device]:group_device' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(unlockVolume)
|
||||||
|
_arguments \
|
||||||
|
'-user[cryptographic user]:user' \
|
||||||
|
'-recoverykeychain[key chain file]:path:_files' \
|
||||||
|
'-passphrase[passphrase]:passphrase' \
|
||||||
|
'-stdinpassphrase[read passphrase from standard input]' \
|
||||||
|
'-nomount[leave volume unmounted]' \
|
||||||
|
'-mountpoint[mountpoint path]:path:_files' \
|
||||||
|
'-systemreadwrite[mount read/write]' \
|
||||||
|
'-verify[test passphrase correctness without affecting the locked or unlocked state]' \
|
||||||
|
'-plist[emit a property list instead of user-formatted output]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(changePassphrase)
|
||||||
|
_arguments \
|
||||||
|
'-user[cryptographic user]:user' \
|
||||||
|
'-oldPassphrase[old passphrase]:old_passphrase' \
|
||||||
|
'-oldStdinpassphrase[read old passphrase from standard input]' \
|
||||||
|
'-newPassphrase[new passphrase]:new_passphrase' \
|
||||||
|
'-newStdinpassphrase[read new passphrase from standard input]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(setPassphraseHint)
|
||||||
|
_arguments \
|
||||||
|
'-user[cryptographic user]:user' \
|
||||||
|
'-hint[hint message]:hint' \
|
||||||
|
'-clear[clear any existing hint]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(encryptVolume)
|
||||||
|
_arguments \
|
||||||
|
'-user[cryptographic user]:user' \
|
||||||
|
'-passphrase[passphrase]:passphrase' \
|
||||||
|
'-stdinpassphrase[read passphrase from standard input]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(decryptVolume)
|
||||||
|
_arguments \
|
||||||
|
'-user[cryptographic user]:user' \
|
||||||
|
'-recoverykeychain[key chain file]:path:_files' \
|
||||||
|
'-passphrase[passphrase]:passphrase' \
|
||||||
|
'-stdinpassphrase[read passphrase from standard input]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(deleteSnapshot)
|
||||||
|
_arguments \
|
||||||
|
'-user[cryptographic user]:user' \
|
||||||
|
'-xid[transaction ID]:xid' \
|
||||||
|
'-name[snapshort name]:name' \
|
||||||
|
'-wait[wait for removing snapshot]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(updatePreboot)
|
||||||
|
_arguments \
|
||||||
|
'-od[open directory path]:dir:_files -/' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_APFS_subcommands] )) ||
|
||||||
|
_diskutil_APFS_subcommands() {
|
||||||
|
local -a commands=(
|
||||||
|
'list:Display APFS objects as a tree'
|
||||||
|
'convert:Convert an HFS volume to an APFS Container with a single APFS Volume'
|
||||||
|
'create:Create an empty APFS Container and add one APFS Volume with the given name'
|
||||||
|
'createContainer:Create an empty APFS Container'
|
||||||
|
'deleteContainer:Destroy an existing APFS Container'
|
||||||
|
'resizeContainer:Resize an existing APFS Container'
|
||||||
|
'addVolume:Add a new APFS Volume to an existing APFS Container'
|
||||||
|
'deleteVolume:Remove the given APFS Volume from its APFS Container'
|
||||||
|
'deleteVolumeGroup:Remove all APFS Volumes from the APFS Container'
|
||||||
|
'eraseVolume:Erase the contents of an existing APFS Volume'
|
||||||
|
'changeVolumeRole:Change the role metadata flags of an existing APFS Volume'
|
||||||
|
'unlockVolume:Unlock the mount an encrypted and locked APFS Volume or verify a passphrase'
|
||||||
|
'lockVolume:Unmount and lock an encrypted unlocked APFS Volume'
|
||||||
|
'listCryptoUsers:Show all cryptographic users and special-purpose users'
|
||||||
|
'changePassphrase:Change the passphrase of the user associated with the given APFS Volume'
|
||||||
|
'setPassphraseHint:Set an arbitrary hint string to aid recall of a passphrase'
|
||||||
|
'encryptVolume:Start encryption of a currently-unencrypted APFS Volume'
|
||||||
|
'decryptVolume:Start decryption of a currently-encrypted APFS Volume'
|
||||||
|
'listSnapshots:Show all APFS Snapshots associated with the given APFS Volume'
|
||||||
|
'deleteSnapshot:Remove the given APFS Snapshot from its APFS Volume'
|
||||||
|
'listGroups:Display the relationships among APFS Volumes which are defined by APFS Volume Groups'
|
||||||
|
'defragment:Manage automatic background defragmentation at the APFS Container or Volume level'
|
||||||
|
"updatePreboot:Update the target volume's associated Preboot Volume"
|
||||||
|
'syncPatchUsers:Perform a specific repair of APFS cryptographic user lock records'
|
||||||
|
)
|
||||||
|
_describe -t commands 'command' commands "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_appleRAID] )) ||
|
||||||
|
_diskutil_appleRAID() {
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
'1: :_diskutil_appleRAID_subcommands' \
|
||||||
|
'*:: :->arg' \
|
||||||
|
&& ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
(arg)
|
||||||
|
case $words[1] in
|
||||||
|
(list)
|
||||||
|
_arguments \
|
||||||
|
'-plist[emit a property list instead of user-formatted output]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(create)
|
||||||
|
_arguments \
|
||||||
|
'1:command:(mirror stripe concat)' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(add)
|
||||||
|
_arguments \
|
||||||
|
'1:type:(member spare)' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(enable)
|
||||||
|
_arguments \
|
||||||
|
'1:command:(mirror concat)' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(update)
|
||||||
|
_arguments \
|
||||||
|
'1:key:(AutoRebuild SetTimeout)' \
|
||||||
|
'2:value' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_appleRAID_subcommands] )) ||
|
||||||
|
_diskutil_appleRAID_subcommands() {
|
||||||
|
local -a commands=(
|
||||||
|
'list:Display AppleRAID volumes with current status and associated member disks'
|
||||||
|
'create:Create a new RAID set consisting of multiple disks and/or RAID sets'
|
||||||
|
'delete:Destroy an existing RAID set'
|
||||||
|
'repairMirror:Repair a degraded mirror'
|
||||||
|
'add:Add a new member or hot spare to an existing RAID set'
|
||||||
|
'remove:Remove a member or spare from an existing RAID set'
|
||||||
|
'enable:Convert a non-RAID disk partition into an RAID set'
|
||||||
|
'update:Update the key-value parameters of an existing RAID set'
|
||||||
|
)
|
||||||
|
_describe -t commands 'command' commands "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_corestorage] )) ||
|
||||||
|
_diskutil_corestorage() {
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
'1: :_diskutil_corestorage_subcommands' \
|
||||||
|
'*:: :->arg' \
|
||||||
|
&& ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
(arg)
|
||||||
|
case $words[1] in
|
||||||
|
(list|info)
|
||||||
|
_arguments \
|
||||||
|
'-plist[emit property list instead of the formatted tree output]' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(unlockVolume)
|
||||||
|
_arguments \
|
||||||
|
'-nomount[not mount automatically]' \
|
||||||
|
'-stdinpassphrase[read password from standard input]' \
|
||||||
|
'-passphrase[passphrase]:passphrase' \
|
||||||
|
'-recoverykeychain[a path to keychain file]:file:_files' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_corestorage_subcommands] )) ||
|
||||||
|
_diskutil_corestorage_subcommands() {
|
||||||
|
local -a commands=(
|
||||||
|
'list:Display a tree view of the CoreStorage world'
|
||||||
|
'info:Display properties of the CoreStorage object'
|
||||||
|
'delete:Delete a CoreStorage logical volume group'
|
||||||
|
'unlockVolume:Unlock a logical volume and file system'
|
||||||
|
)
|
||||||
|
_describe -t commands 'command' commands "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_image] )) ||
|
||||||
|
_diskutil_image() {
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
'--stdinpassphrase[read the passphrase from stdin]' \
|
||||||
|
'--verbose[enable verbose output]' \
|
||||||
|
'--plist[produce output in a plist format]' \
|
||||||
|
'1: :_diskutil_image_subcommands' \
|
||||||
|
'*:: :->arg' \
|
||||||
|
&& ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
(arg)
|
||||||
|
case $words[1] in
|
||||||
|
(attach)
|
||||||
|
_arguments \
|
||||||
|
'--readOnly[disk image is attached read-only]' \
|
||||||
|
'--nobrowse[hide the mounted volume in the disk image from GUI applications]' \
|
||||||
|
'--mountPoint[path to mount the image]:mount_point:_files -/' \
|
||||||
|
'--mountOptions[comma separated mount options]:option' \
|
||||||
|
'--mountPolicy[mount policy]:policy:(noMount autoMount forceMount)' \
|
||||||
|
'--noMount[skip any mount attempts and only attach the disk image]' \
|
||||||
|
'*--shadow[shadow file path]:file:_files' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(info)
|
||||||
|
_arguments \
|
||||||
|
'--extra[additional information will be retrieved for some image types]' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(create)
|
||||||
|
_diskutil_image_create && ret=0
|
||||||
|
;;
|
||||||
|
(resize)
|
||||||
|
_arguments \
|
||||||
|
'(-s --size)'{-s,--size}'[new size of the disk image]:size' \
|
||||||
|
'--image-only[only resize the disk image and adjust a secondary GPT table to the new size]' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_image_subcommands] )) ||
|
||||||
|
_diskutil_image_subcommands() {
|
||||||
|
local -a commands=(
|
||||||
|
'attach:Attach a disk image as a device'
|
||||||
|
'info:Print out information includes about a disk image'
|
||||||
|
'chpass:Change the passphrase of a given encrypted image'
|
||||||
|
'create:Create a disk image'
|
||||||
|
'resize:Resizes an existing disk image represented by given URL'
|
||||||
|
)
|
||||||
|
_describe -t commands 'command' commands "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_image_create] )) ||
|
||||||
|
_diskutil_image_create() {
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
'1: :_diskutil_image_create_subcommands' \
|
||||||
|
'*:: :->arg' \
|
||||||
|
&& ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
(arg)
|
||||||
|
case $words[1] in
|
||||||
|
(blank)
|
||||||
|
_arguments \
|
||||||
|
'--format[disk format]:format:(RAW ASIF USDB)' \
|
||||||
|
'--size[disk size]:size' \
|
||||||
|
'--volumeName[volume name]:name' \
|
||||||
|
'-fs[create a file system in the specified format]:format:(APFS ExFAT MS-DOS)' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(from)
|
||||||
|
_arguments \
|
||||||
|
'--format[disk format]:format:(RAW UDRO UDZO ULFO ULMO ASIF UDSB)' \
|
||||||
|
'--shadow[path to the shadow file]:path:_files' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_diskutil_image_create_subcommands] )) ||
|
||||||
|
_diskutil_image_create_subcommands() {
|
||||||
|
local -a commands=(
|
||||||
|
'blank:create a blank disk image'
|
||||||
|
'from:create a disk image from source'
|
||||||
|
)
|
||||||
|
_describe -t commands 'command' commands "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_diskutil "$@"
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
# Description
|
# Description
|
||||||
# -----------
|
# -----------
|
||||||
#
|
#
|
||||||
# Completion script for networkQuality on macOS
|
# Completion script for networkQuality on macOS 26
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Authors
|
# Authors
|
||||||
|
|
@ -35,13 +35,21 @@
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
|
'-b[Show Bonjour advertised networkQuality servers]' \
|
||||||
|
'-B[Run against specified Bonjour instance]:name' \
|
||||||
'-C[Use custom configuration URL or path]:url_or_path' \
|
'-C[Use custom configuration URL or path]:url_or_path' \
|
||||||
|
'-f[Force usage of a specific protocol selection]:option:(h1 h2 h3 L4S noL4S)' \
|
||||||
'-I[Bind test to interface]:interface:_net_interfaces' \
|
'-I[Bind test to interface]:interface:_net_interfaces' \
|
||||||
|
'-M[Maximum runtime in seconds]:seconds' \
|
||||||
'-r[Connect to host or IP]:host' \
|
'-r[Connect to host or IP]:host' \
|
||||||
'-c[Produce computer-readable output]' \
|
'-S[Create a networkQuality server-instance running locally on the specified port]:port' \
|
||||||
|
'-c[Produce computer-readable output]:file:_files' \
|
||||||
|
'-d[Do not run a download test(implies -s)]' \
|
||||||
'-h[Show help]' \
|
'-h[Show help]' \
|
||||||
'-k[Disable verification of the server identity via TLS]' \
|
'-k[Disable verification of the server identity via TLS]' \
|
||||||
|
'-p[Use iCloud Private Relay]' \
|
||||||
'-s[Run tests sequentially instead of parallel upload/download]' \
|
'-s[Run tests sequentially instead of parallel upload/download]' \
|
||||||
|
'-u[Do not run an upload test(implies -s)]' \
|
||||||
'-v[Verbose output]'
|
'-v[Verbose output]'
|
||||||
|
|
||||||
# Local Variables:
|
# Local Variables:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
#compdef rev
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for rev v2.41 (https://github.com/util-linux/util-linux)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'(- *)'{-h,--help}'[display this help]' \
|
||||||
|
'(- *)'{-V,--version}'[display version]' \
|
||||||
|
'(-0 --zero)'{-0,--zero}'[use the nul character as line separator]'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
# Description
|
# Description
|
||||||
# -----------
|
# -----------
|
||||||
#
|
#
|
||||||
# Completion script for screencapture command
|
# Completion script for screencapture command macOS 26
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Authors
|
# Authors
|
||||||
|
|
@ -46,7 +46,6 @@ _arguments \
|
||||||
'-p[screen capture will use the default settings for capture]' \
|
'-p[screen capture will use the default settings for capture]' \
|
||||||
'-M[screen capture output will go to a new Mail message]' \
|
'-M[screen capture output will go to a new Mail message]' \
|
||||||
'-P[screen capture output will open in Preview or QuickTime Player]' \
|
'-P[screen capture output will open in Preview or QuickTime Player]' \
|
||||||
'-I[screen capture output will open in Messages]' \
|
|
||||||
'-B[screen capture output will open in app with bundle ID]:bundle_id:' \
|
'-B[screen capture output will open in app with bundle ID]:bundle_id:' \
|
||||||
'(-b -i -w -W)-s[only allow mouse selection mode]' \
|
'(-b -i -w -W)-s[only allow mouse selection mode]' \
|
||||||
'-S[in window capture mode, capture the screen not the window]' \
|
'-S[in window capture mode, capture the screen not the window]' \
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
#compdef textutil
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for textutil command macOS 26
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local -a format=(txt html rtf rtfd doc docx wordml odt webarchive)
|
||||||
|
|
||||||
|
_arguments -S \
|
||||||
|
'-help[Show the usage information for the command and exit]' \
|
||||||
|
'-info[Display information about the specified files]' \
|
||||||
|
'-convert[Convert the specified files to the indicated format and write]:format:'"($format)" \
|
||||||
|
'-cat[Read the specified files, concatenate them in the indicated format]:format:'"($format)" \
|
||||||
|
'-extension[Specify an extension to be used for output files]:ext' \
|
||||||
|
'-output[Specify the file name to be used for the first output file]:path:_files' \
|
||||||
|
'-stdin[Specify that input should be read from stdin rather than from files]' \
|
||||||
|
'-stdout[Specify that the first output file should go to stdout]' \
|
||||||
|
'-encoding[Specify the encoding to be used for plain text or HTML output files]:encode' \
|
||||||
|
'-inputencoding[Force all plain text input files to be interpreted using the specified encoding]' \
|
||||||
|
'-format[Force all input files to be interpreted using the indicated format]:format:'"($format)" \
|
||||||
|
'-font[Specify the name of the font to be used for converting plain to rich text]:font' \
|
||||||
|
'-fontsize[Specify the size in points of the font to be used for converting plain to rich text]:size' \
|
||||||
|
'-noload[Do not load subsidiary resources]' \
|
||||||
|
'-nostore[Do not write out subsidiary resources]' \
|
||||||
|
'-baseurl[Specify a base URL to be used for relative URLs]:url' \
|
||||||
|
'-timeout[Specify the time in seconds to wait for resources to load]' \
|
||||||
|
'-textsizemultiplier[Specify a numeric factor by which to multiply font sizes]' \
|
||||||
|
'-excludeelements[Specify which HTML elements should not used in generated HTML]:tags' \
|
||||||
|
'-prefixspaces[Specify the number of spaces by which to indent nested elements]:spaces' \
|
||||||
|
'-strip[Do not copy metadata from input files to output files]' \
|
||||||
|
'-title[Specify the title metadata attribute for output files]:title' \
|
||||||
|
'-author[Specify the author metadata attribute for output files]:author' \
|
||||||
|
'-subject[Specify the subject metadata attribute for output files]:subject' \
|
||||||
|
'-keywords[Specify the keywords metadata attribute for output files]:keywords' \
|
||||||
|
'-comment[Specify the comment metadata attribute for output files]:comment' \
|
||||||
|
'-editor[Specify the editor metadata attribute for output files]:editor' \
|
||||||
|
'-company[Specify the company metadata attribute for output files]:company' \
|
||||||
|
'-creationtime[Specify the creation time metadata attribute for output files]:creation_time' \
|
||||||
|
'-modificationtime[Specify the modification time metadata attribute for output files]:modification_time' \
|
||||||
|
'*:: :_files'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
#compdef vipw
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for vipw v4.17 (https://github.com/shadow-maint/shadow)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'(- *)'{-h,--help}'[display this help]' \
|
||||||
|
'(-g --group -p --passwd)'{-g,--group}'[edit group database]' \
|
||||||
|
'(-g --group -p --passwd)'{-p,--passwd}'[edit passwd database]' \
|
||||||
|
'(-q --quiet)'{-q,--quiet}'[quiet mode]' \
|
||||||
|
'(-R --root)'{-R,--root}'[apply changes in the given directory]:dir:_files -/' \
|
||||||
|
'(-s --shadow)'{-s,--shadow}'[eedit shadow or gshadow database]'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
#compdef wdctl
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for wdctl v2.41 (https://github.com/util-linux/util-linux)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(( $+functions[_wdctl_output_columns] )) ||
|
||||||
|
_wdctl_output_columns() {
|
||||||
|
local -a columns=(
|
||||||
|
"FLAG[flag name]"
|
||||||
|
"DESCRIPTION[flag description]"
|
||||||
|
"STATUS[flag status]"
|
||||||
|
"BOOT-STATUS[flag boot status]"
|
||||||
|
"DEVICE[watchdog device name]"
|
||||||
|
)
|
||||||
|
|
||||||
|
_values -s ',' column $columns
|
||||||
|
}
|
||||||
|
|
||||||
|
_arguments -s \
|
||||||
|
'(- *)'{-h,--help}'[display this help]' \
|
||||||
|
'(- *)'{-V,--version}'[display version]' \
|
||||||
|
'(-f --flags)'{-f,--flags}'[print selected flags only]:flags' \
|
||||||
|
'(-F --noflags)'{-F,--noflags}'[do not print information about flags]' \
|
||||||
|
'(-I --noident)'{-I,--noident}'[do not print watchdog identity information]' \
|
||||||
|
'(-n --noheadings)'{-n,--noheadings}'[do not print headings for flags table]' \
|
||||||
|
'(-O --oneline)'{-O,--oneline}'[print all information on one line]' \
|
||||||
|
'(-o --output)'{-o,--output}'[output columns]:columns:_wdctl_output_columns' \
|
||||||
|
'(-p --setpretimeout)'{-p,--setpretimeout}'[set watchdog pre-timeout]:seconds' \
|
||||||
|
'(-g --setpregovernor)'{-g,--setpregovernor}'[set pre-timeout governor]:name' \
|
||||||
|
'(-r --raw)'{-r,--raw}'[use raw output format for flags table]' \
|
||||||
|
'(-T --notimeouts)'{-T,--notimeouts}'[do not print watchdog timeouts]' \
|
||||||
|
'(-s --settimeout)'{-s,--settimeout}'[set watchdog timeout]:seconds' \
|
||||||
|
'(-x --flags-only)'{-x,--flags-only}'[print only flags table]'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
#compdef yamllint
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for yamllint 1.37.1 (https://github.com/adrienverge/yamllint)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'(- *)'{-h,--help}'[show help message and exit]' \
|
||||||
|
'(-c --config-file)'{-c,--config-file}'[path to a custom configuration]:config:_files' \
|
||||||
|
'(-d --config-data)'{-d,--config-data}'[custom configuration(as YAML source)]:data' \
|
||||||
|
'(- *)--list-files[list files to lint and exit]' \
|
||||||
|
'(-f --format)'{-f,--format}'[format for parsing output]:format:(parsable standard colored github auto)' \
|
||||||
|
'(-s --strict)'{-s,--strict}'[return non-zero exit code on warnings as well as errors]' \
|
||||||
|
'--no-warnings[output only error level problems]' \
|
||||||
|
'(- *)'{-v,--version}'[show program version number and exit]' \
|
||||||
|
'*:: :_files -g "*.(yaml|yml)"'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
#compdef zramctl
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for zramctl v2.41 (https://github.com/util-linux/util-linux)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(( $+functions[_zramctl_output_columns] )) ||
|
||||||
|
_zramctl_output_columns() {
|
||||||
|
local -a columns=(
|
||||||
|
"NAME[zram device name]"
|
||||||
|
"DISKSIZE[limit on the uncompressed amount of data]"
|
||||||
|
"DATA[uncompressed size of stored data]"
|
||||||
|
"COMPR[compressed size of stored data]"
|
||||||
|
"ALGORITHM[the selected compression algorithm]"
|
||||||
|
"STREAMS[number of concurrent compress operations]"
|
||||||
|
"ZERO-PAGES[empty pages with no allocated memory]"
|
||||||
|
"TOTAL[all memory including allocator fragmentation and metadata overhead]"
|
||||||
|
"MEM-LIMIT[memory limit used to store compressed data]"
|
||||||
|
"MEM-USED[memory zram have been consumed to store compressed data]"
|
||||||
|
"MIGRATED[number of objects migrated by compaction]"
|
||||||
|
"COMP-RATIO[compression ratio: DATA/TOTAL]"
|
||||||
|
"MOUNTPOINT[where the device is mounted]"
|
||||||
|
)
|
||||||
|
|
||||||
|
_values -s ',' column $columns
|
||||||
|
}
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'(- *)'{-h,--help}'[display this help]' \
|
||||||
|
'(- *)'{-V,--version}'[display version]' \
|
||||||
|
'(-a --algorithm)'{-a,--algorithm}'[compression algorithm to use]:algorithm:(lzo lz4 lz4hc deflate 842 zstd)' \
|
||||||
|
'(-b --bytes)'{-b,--bytes}'[print sizes in bytes rather than in human readable format]:bytes' \
|
||||||
|
'(-f --find)'{-f,--find}'[find a free device]' \
|
||||||
|
'(-n --noheadings)'{-n,--noheadings}'[do not print headings]' \
|
||||||
|
'(-o --output)'{-o,--output}'[output columns]:columns:_zramctl_output_columns' \
|
||||||
|
'(-o --output --output-all)--output-all[output all columns]' \
|
||||||
|
'(-p --algorithm-params)'{-p,--algorithm-params}'[algorithm parameters to use]' \
|
||||||
|
'--raw[use raw status output format]' \
|
||||||
|
'(-r --reset)'{-r,--reset}'[reset all specified devices]' \
|
||||||
|
'(-s --size)'{-s,--size}'[device size]:size' \
|
||||||
|
'(-t --streams)'{-t,--streams}'[number of compression streams]:number'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
@ -0,0 +1,454 @@
|
||||||
|
* 目录
|
||||||
|
- [[#介绍][介绍]]
|
||||||
|
- [[#开始][开始]]
|
||||||
|
- [[#让zsh知道用哪个函数补全命令][让zsh知道用哪个函数补全命令]]
|
||||||
|
- [[#补全gnu格式命令][补全gnu格式命令]]
|
||||||
|
- [[#从其它命令复制补全][从其它命令复制补全]]
|
||||||
|
- [[#编写你自己的补全代码][编写你自己的补全代码]]
|
||||||
|
- [[#工具函数][工具函数]]
|
||||||
|
- [[#用_describe编写简单的补全函数][用_describe编写简单的补全函数]]
|
||||||
|
- [[#用_alternative编写补全函数][用_alternative编写补全函数]]
|
||||||
|
- [[#用_arguments编写补全函数][用_arguments编写补全函数]]
|
||||||
|
- [[#用_regex_arguments和_regex_words编写补全函数][用_regex_arguments和_regex_words编写补全函数]]
|
||||||
|
- [[#用_values_sep_parts和_multi_parts实现复杂补全][用_values、_sep_parts和_multi_parts实现复杂补全]]
|
||||||
|
- [[#用compadd直接添加补全词][用compadd直接添加补全词]]
|
||||||
|
- [[#测试与debug][测试与debug]]
|
||||||
|
- [[#踩坑了吧-需要小心的东西][踩坑了吧 (需要小心的东西)]]
|
||||||
|
- [[#小贴士][小贴士]]
|
||||||
|
- [[#其它资源][其它资源]]
|
||||||
|
|
||||||
|
> 译注:本文可能有不通顺的地方,或者采用的词汇不是很正确。
|
||||||
|
> 如果你有更好的主意,欢迎提交PR。
|
||||||
|
|
||||||
|
* 介绍
|
||||||
|
Zsh官方的补全函数文档令人费解,而且也没提供多少示例。
|
||||||
|
写这份文档的当下我已经在网上找到了其它几份教程,但是那些教程只涉及了补全系统的一小部分。
|
||||||
|
这份文档目的在于补全网上其它地方没涵盖的部分,同时附带示例,这样读者就可以学会如何写更高级的补全函数。
|
||||||
|
我不会展开每一细节,但给你提供的内容和示例足以从零开始。
|
||||||
|
如果你需要了解更多细节,你可以自行查询[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][官方文档]]。
|
||||||
|
|
||||||
|
还请公开你所创作的任何脚本(比如fork这个仓库然后[[id:64bcd501-b0f0-48c7-b8e2-07af708b95ec][pr]])。
|
||||||
|
此外如果你有任何更多补充内容或对此教程的改进,欢迎做贡献。
|
||||||
|
* 开始
|
||||||
|
** 让zsh知道用哪个函数补全命令
|
||||||
|
补全命令用的补全函数储存于名字以下划线“_”起始的文件,这些文件应存于$fpath变量所列出的某目录中。
|
||||||
|
你可以将下面的代码写入你的~/.zshrc以在$fpath中新增目录:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
fpath=(~/newdir $fpath)
|
||||||
|
#+END_SRC
|
||||||
|
一个补全函数文件的第一行长这个样:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
#compdef foobar
|
||||||
|
#+END_SRC
|
||||||
|
这行代码表示这个文件含有补全foobar命令的代码。
|
||||||
|
多数情况下第一行都采用这个格式,但你也可以用同一个文件补全多个不同的函数。
|
||||||
|
查阅[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Autoloaded-files][官方文档]]以了解更多细节。
|
||||||
|
|
||||||
|
你也可以直接使用compdef命令(比如在你的~/.zshrc文件里)来告诉zsh用哪个函数补全命令:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
> compdef _function foobar
|
||||||
|
#+END_SRC
|
||||||
|
或者对多个命令使用同一种补全:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
> compdef _function foobar goocar hoodar
|
||||||
|
#+END_SRC
|
||||||
|
如果你想提供参数的话:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
> compdef '_function arg1 arg2' foobar
|
||||||
|
#+END_SRC
|
||||||
|
查阅[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Functions-4][官方文档]]以了解更多细节。
|
||||||
|
** 补全gnu格式命令
|
||||||
|
很多[[https://www.gnu.org/][gnu]]命令以标准化的方式列出选项描述(使用--help选项时)。
|
||||||
|
对于这些命令你可以使用_gnu_generic函数自动创建补全,比如这样:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
> compdef _gnu_generic foobar
|
||||||
|
#+END_SRC
|
||||||
|
或者对多个不同命令使用_gnu_generic:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
> compdef _gnu_generic foobar goocar hoodar
|
||||||
|
#+END_SRC
|
||||||
|
你可以把这行代码放进~/.zshrc文件里。
|
||||||
|
** 从其它命令复制补全
|
||||||
|
如果你想要让一个命令(比如cmd1)和另一个已有补全的命令(比如cmd2)拥有相同的补全,你可以:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
> compdef cmd1=cmd2
|
||||||
|
#+END_SRC
|
||||||
|
比如当你给一个命令创建了一个助记alias的时候会很有帮助。
|
||||||
|
* 编写你自己的补全代码
|
||||||
|
你可以通过阅读已有的补全函数来开始入门。
|
||||||
|
在我的Linux系统上这些补全函数在/usr/share/zsh/functions/Completion/Unix、
|
||||||
|
/usr/share/zsh/functions/Completion/Linux和一些其它子目录下。
|
||||||
|
|
||||||
|
你会注意到这些文件频繁使用_arguments函数。
|
||||||
|
该函数是一个工具函数,可用于编写简单的补全函数。
|
||||||
|
_arguments函数是一个compadd内置函数的包装函数。
|
||||||
|
compadd内置函数是一个核心函数,用于向命令行加入补全词,并控制其行为。
|
||||||
|
不过,多数情况下你不需要使用compadd,因为有很多更易于使用的工具函数,如_arguments和_describe。
|
||||||
|
|
||||||
|
对于非常基础的补全,_describe函数已经够用了。
|
||||||
|
|
||||||
|
** 工具函数
|
||||||
|
下面是一个工具函数列表,你或许会用到它们。
|
||||||
|
工具函数的完整列表及使用方法在[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions][此]]可供查阅。
|
||||||
|
这些函数的使用示例在下一节给出。
|
||||||
|
|
||||||
|
> 译注:从这里开始会出现一些术语,如定义(specification)、描述(description)、动作(action)、词汇(word)等。
|
||||||
|
> 初次阅读可能会觉得比较困难,尤其是下面的工具函数表格,稍后教程开始一一讲解并给出示例的时候就好懂多了。
|
||||||
|
> 定义指的是对补全规则的定义,如`_describe 定义`。
|
||||||
|
> 描述当然指的是对命令行选项和参数的用户友好描述,补全时会显示在屏幕上,如:'-o 输出文件'
|
||||||
|
> 词汇指的是如同'word'、'-o'、'--help'、'start'等连续的一小段字符串
|
||||||
|
> 动作指的是匹配成功后执行的操作,比如执行某函数生成补全,或直接补全等等。
|
||||||
|
> 选项(option)和参数指给命令提供的选项和参数,如`cp -r src dst`中,`-r`为选项,`src`和`dst`为参数。有些选项带参,如`tar -f file ...`中`-f`选项带`file`参数。
|
||||||
|
> 候选(candidate)指可能的补全结果,如补全`tar -f`时目录下所有文件会被作为候选,补全`systemctl`时`start`、`stop`、`list-units`等指令会被作为候选。
|
||||||
|
> 还请不要感到灰心,读下去就是了。
|
||||||
|
|
||||||
|
*** 用于大部分补全的主要工具函数
|
||||||
|
| _alternative | 从其它工具函数或shell代码生成补全候选。 |
|
||||||
|
| _arguments | 指定如何补全一命令的各选项和参数(命令选项风格为unix风格)。 |
|
||||||
|
| _describe | 创建由带描述的词汇(但不包含动作)组成的简单补全。比_arguments更简单。 |
|
||||||
|
| _gnu_generic | 为带有“--help”选项的命令补全选项。 |
|
||||||
|
| _regex_arguments | 创建一先用regex表达式匹配命令行参数再执行动作/补全的函数。 |
|
||||||
|
*** 对单个词汇进行复杂补全的工具函数
|
||||||
|
| _values | 补全任意词汇(值)及其参数,或逗号分隔的词汇与参数列表。 |
|
||||||
|
| _combination | 补全值的组合,比如域名和用户名的二元组。 |
|
||||||
|
| _multi_parts | 对词汇的由符号分隔的多个部分分别补全,比如补全路径:/u/i/sy -> /usr/include/sys |
|
||||||
|
| _sep_parts | 类似_multi_parts但在补全的不同部分中允许不同的分隔符。 |
|
||||||
|
| _sequence | 包装另一补全函数,并补全由该函数生成的匹配列表。 |
|
||||||
|
*** 用于补全特定对象种类的函数
|
||||||
|
| _path_files | 补全文件目录。用多个选项控制行为。 |
|
||||||
|
| _files | 使用所有选项调用_path_files,除了-g和-/。这些选项取决于file-patterns风格设置。 |
|
||||||
|
| _net_interfaces | 补全网络接口名称。 |
|
||||||
|
| _users | 补全用户名 |
|
||||||
|
| _groups | 补全组名 |
|
||||||
|
| _options | 补全shell选项名。 |
|
||||||
|
| _parameters | 补全shell参数/变量名(可用模式匹配限制要补全的参数/变量名)。 |
|
||||||
|
*** 处理已缓存的补全的函数
|
||||||
|
如果你有大量的补全,你可以将补全保存于一个缓存文件以快速加载。
|
||||||
|
| _cache_invalid | 指明补全缓存是否需要重新构建(rebuild),缓存由标识符指定 |
|
||||||
|
| _retrieve_cache | 从缓存文件获取补全信息 |
|
||||||
|
| _store_cache | 储存缓存于缓存文件,缓存由标识符指定 |
|
||||||
|
*** 其它函数
|
||||||
|
| _message | 当无补全可生成时显示帮助信息。 |
|
||||||
|
| _regex_words | 为_regex_arguments命令生成参数。比手写参数更简单。 |
|
||||||
|
| _guard | 检查被补全的词汇,用于_arguments和类似函数的定义的ACTION中。 |
|
||||||
|
*** 动作(Actions)
|
||||||
|
许多工具函数,如_arguments、_regex_arguments、_alternative和_values,在选项/参数末尾有一个action。
|
||||||
|
这个action指定如何补全对应的参数。
|
||||||
|
这些action可以是如下形式之一:
|
||||||
|
| ( ) | 需要提供参数但未生成任何匹配 |
|
||||||
|
| (ITEM1 ITEM2) | 匹配列表 |
|
||||||
|
| ((ITEM1\:'DESC1' ITEM2\:'DESC2')) | 匹配列表,带有描述。引号必须和整个定义所使用的引号不同。 |
|
||||||
|
| ->STRING | 将$state设为STRING然后继续(可在调用工具函数后用case语句检查$state的值) |
|
||||||
|
| FUNCTION | 生成匹配或完成其它操作的函数的函数名,比如_files或_message |
|
||||||
|
| {EVAL-STRING} | 把字符串当作shell代码执行(evaluate)。可用于带参调用工具函数,如_values或_describe |
|
||||||
|
| =ACTION | 在补全命令行中插入占位词汇不改变补全点。 |
|
||||||
|
|
||||||
|
并非所有的action种类都可用于使用action的工具函数。比如->STRING类不可用于_regex_arguments或_alternative函数。
|
||||||
|
** 用_describe编写简单的补全函数
|
||||||
|
_describe函数可以用于简单的补全,此类补全的选项/参数的位置与顺序无关紧要。
|
||||||
|
你只需用一个数组参数储存这些选项和其描述,然后将数组参数的名作为参数传入_describe。
|
||||||
|
下面的示例创建补全候选c和d(注意代码文件名应为_cmd,并且文件存于$fpath所列出的目录之下)。
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
#compdef cmd
|
||||||
|
local -a subcmds
|
||||||
|
subcmds=('c:c命令描述' 'd:d命令描述')
|
||||||
|
_describe 'command' subcmds
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
你可以像下面一样使用由双横杠分隔的列表,但注意实操时会混合匹配结果,所以不应该用于不同种类的补全候选:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
local -a subcmds topics
|
||||||
|
subcmds=('c:c命令描述' 'd:d命令的描述')
|
||||||
|
topics=('e:e帮助主题的描述' 'f:f帮助主题的描述')
|
||||||
|
_describe 'command' subcmds -- topics
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
如果两个候选有相同的描述,_describe把它们集于一行,并确保描述严格按列对齐。
|
||||||
|
_describe函数可用在_alternative、_arguments或_regex_arguments的ACTION中。
|
||||||
|
在这种情况下你需要用括号将_describe和参数包起来,比如'TAG:DESCRIPTION:{_describe 'values' options}'
|
||||||
|
** 用_alternative编写补全函数
|
||||||
|
如同_describe,该函数进行简单补全,其选项/参数的顺序和位置并不重要。
|
||||||
|
然而,与_describe的固定匹配不同,_alternative可进一步调用函数生成补全候选。
|
||||||
|
此外,_alternative允许混合不同种类的补全候选。
|
||||||
|
|
||||||
|
关于参数,该函数接受一列定义(specification),每项定义的形式为“TAG:DESCRIPTION:ACTION”(即“标签:描述:动作”),其中TAG是一个标识补全匹配种类的特殊标签。
|
||||||
|
DESCRIPTION以标题(heading)的形式描述补全候选组,而ACTION是先前列出的动作种类之一(除了->STRING和=ACTION之外)。
|
||||||
|
例如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_alternative 'arguments:自定义参数:(a b c)' 'files:文件名:_files'
|
||||||
|
#+END_SRC
|
||||||
|
第一个定义增加了补全候选a、b和c,而第二个定义调用_files函数以补全文件目录。
|
||||||
|
|
||||||
|
我们可以用反斜杠 \ 将不同定义分成几行并给每个自定义参数加入描述文字:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_alternative \
|
||||||
|
'args:自定义参数:((a\:"描述a" b\:"描述b" c\:"描述c"))' \
|
||||||
|
'files:文件名:_files'
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
如果我们想向_files传递参数,我们可以直接写在_files后面:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_alternative \
|
||||||
|
'args:自定义参数:((a\:"描述a" b\:"描述b" c\:"描述c"))' \
|
||||||
|
'files:文件名:_files -/'
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
如要用变量展开创建补全列表,必须用双引号将定义括起来,
|
||||||
|
如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_alternative \
|
||||||
|
"dirs:用户目录:($userdirs)" \
|
||||||
|
"pids:进程ID:($(ps -A o pid=))"
|
||||||
|
#+END_SRC
|
||||||
|
在此例子中第一个定义加入$userdirs变量中的词汇,第二个定义执行'ps -A o pid='并获取pid表,pid表用作补全候选。
|
||||||
|
实操中,我们使用已有的_pids函数,而不是像上面那样手写。
|
||||||
|
|
||||||
|
我们可以在ACTION中使用_values等其它工具函数以完成更复杂的补全,如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_alternative \
|
||||||
|
"directories:用户目录:($userdirs)" \
|
||||||
|
'options:逗号分隔选项: _values -s , letter a b c'
|
||||||
|
#+END_SRC
|
||||||
|
该示例补全$userdirs里的项目,以及用逗号分隔的、含有a、b和/或c的列表。
|
||||||
|
注意_values前面的空格。空格不可省略,因为_values不能接受标准compadd描述选项。
|
||||||
|
|
||||||
|
和_describe一样,_alternative可用作ACTION并作为_arguments或_regex_arguments的一部分。
|
||||||
|
** 用_arguments编写补全函数
|
||||||
|
只需要调用_arguments函数一次就可以创造出非常智能的补全函数。该函数本身就是用于处理这种带有带参选项的命令的。
|
||||||
|
如同_alternative函数,_arguments接受一列定义字符串参数。
|
||||||
|
这些定义字符串指定选项和任何对应的选项参数(如:-f 文件名),或命令参数。
|
||||||
|
|
||||||
|
简单的选项定义用'-OPT[DESCRIPTION]'(即'-选项[描述]'),比如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_arguments '-s[排序后输出]' '--l[更多输出]' '-l[更多输出]'
|
||||||
|
#+END_SRC
|
||||||
|
选项参数可在选项描述后指定,形式用'-OPT[DESCRIPTION]:MESSAGE:ACTION'(即'-选项[描述]:消息:动作'),
|
||||||
|
其中MESSAGE是待显示的信息,而ACTION可以是前面的动作(Actions)章节提到的任何形式。
|
||||||
|
比如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_arguments '-f[输入文件]:文件名:_files'
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
命令参数定义用'N:MESSAGE:ACTION'(即'N:消息:动作'),其中N指定这是第N个命令参数,而MESSAGE和ACTION都和前面的一样。
|
||||||
|
如果N被省略,则其仅表示这是(在所有已定义的参数之后的)下一个参数。如果开头(在N后面)用的是双冒号,则参数非必需。
|
||||||
|
比如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_arguments '-s[排序后输出]' '1:第一个参数:_net_interfaces' '::可选参数:_files' ':下一个参数:(a b c)'
|
||||||
|
#+END_SRC
|
||||||
|
这里第一个参数是网络接口,下一个可选参数是一个文件名,最后一个参数可以是a、b或c,而-s选项可以在任何位置被补全。
|
||||||
|
|
||||||
|
_arguments函数允许所有ACTION形式(在前面的动作(Actions)章节列出)。
|
||||||
|
这表示你可以用动作来选择case语句分支,如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_arguments '-m[音乐文件]:文件名:->files' '-f[flags]:flag:->flags'
|
||||||
|
case "$state" in
|
||||||
|
files)
|
||||||
|
local -a music_files
|
||||||
|
music_files=( Music/**/*.{mp3,wav,flac,ogg} )
|
||||||
|
_multi_parts / music_files
|
||||||
|
;;
|
||||||
|
flags)
|
||||||
|
_values -s , 'flags' a b c d e
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
#+END_SRC
|
||||||
|
在此例子中指向音乐文件的路径被_multi_parts一步步地沿目录下降补全,
|
||||||
|
而flags被_values函数按照逗号分隔列表补全。
|
||||||
|
|
||||||
|
我已经介绍了_arguments定义的基础部分,你还可以定义互斥选项、重复选项和参数、以+开头的选项等。有关更多细节,查阅[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][官方文档]]。
|
||||||
|
同时你也可以看看本文末尾列出的教程,以及[[https://github.com/vapniks/zsh-completions/tree/master/src][src目录]]下的补全函数。
|
||||||
|
** 用_regex_arguments和_regex_words编写补全函数
|
||||||
|
如果你的命令行定义比较复杂,有多个可能的参数序列,那你可能需要_regex_arguments函数。
|
||||||
|
该函数也适用于有一系列跟着多个参数的关键词的情况。
|
||||||
|
|
||||||
|
_regex_arguments创建名字由第一个参数给出的补全函数。
|
||||||
|
因此你需要先调用_regex_arguments来创建补全函数,然后再调用该函数,比如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_regex_arguments _cmd OTHER_ARGS..
|
||||||
|
_cmd "$@"
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
OTHER_ARGS(即“其它参数”)是一序列用于在命令行上匹配和补全词汇的定义。
|
||||||
|
这些序列可被'|'分隔来表示备选词汇序列。
|
||||||
|
你可以用任意嵌套深度的括号来指定备选序列,但括号必须带反斜杠前缀,如\( \),或用引号括起来,如'(' ')'。
|
||||||
|
|
||||||
|
比如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_regex_arguments _cmd 序列1 '|' 序列2 \( 序列2a '|' 序列2b \)
|
||||||
|
_cmd "$@"
|
||||||
|
#+END_SRC
|
||||||
|
该示例定义一个匹配序列1或序列2后跟着序列2a或序列2b的命令行。这种方式和正则表达式语法类似。
|
||||||
|
|
||||||
|
一个序列中的每个定义必须在开头包含一个/ PATTERN/ (即/ 模式/)部分,后跟着可选的':TAG:DESCRIPTION:ACTION'(即':标签:描述:动作')部分。
|
||||||
|
|
||||||
|
每个PATTERN是一个匹配一命令行词汇的正则表达式。这些模式按顺序匹配,直到某个模式不匹配,不匹配的模式将执行对应的ACTION(动作)以进行补全。
|
||||||
|
注意,一定要有一个匹配命令自身的模式。
|
||||||
|
下面有对PATTERN(模式)更详细的解释。
|
||||||
|
|
||||||
|
':TAG:DESCRIPTION:ACTION'的使用方法和_alternative相同,只是开头多了个冒号“:”,并且前面列出的所有ACTION格式都可用。
|
||||||
|
|
||||||
|
例如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_regex_arguments _cmd /$'[^\0]##\0'/ \( /$'word1(a|b|c)\0'/ ':word:first word:(word1a word1b word1c)' '|'\
|
||||||
|
/$'word11(a|b|c)\0'/ ':word:first word:(word11a word11b word11c)' \( /$'word2(a|b|c)\0'/ ':word:second word:(word2a word2b word2c)'\
|
||||||
|
'|' /$'word22(a|b|c)\0'/ ':word:second word:(word22a word22b word22c)' \) \)
|
||||||
|
_cmd "$@"
|
||||||
|
#+END_SRC
|
||||||
|
TODO 英文原文和例子有出入
|
||||||
|
|
||||||
|
在这个例子中第一个词可以是word1(即“词1”,下同)或者word11后紧跟a、b或c,并且如果第一个词含有11,则第二个词可以是word2后紧跟a、b或c,或一个文件名。
|
||||||
|
|
||||||
|
如果感觉太复杂,你也可以用更简单的_regex_words函数达到相同效果。
|
||||||
|
*** 模式
|
||||||
|
你可能注意到了上个例子中的/ PATTERN/和普通的正则表达式不太一样。
|
||||||
|
通常使用的是形如$'foo\0'的字符串参数。这是为了让\0表示成null字符,而zsh内部用来分隔词汇的也是null字符。
|
||||||
|
如果不在末尾包含\0的话,可能会无法匹配下一个词。如果你要把一个变量的值作为模式的一部分,你可以用双括号包起来,
|
||||||
|
这样变量就会展开,然后再在后面加个包含null字符的字符串参数,比如:"$somevar"$'\0'(somevar即“某变量”)。
|
||||||
|
|
||||||
|
表示模式用的正则表达式语法和正常的正则表达式不太一样,但我也找不到有关的文档。
|
||||||
|
不过我还是试图搞清楚了这些特殊字符的意义:
|
||||||
|
| * | 通配符 - 任何数量的字符 |
|
||||||
|
| ? | 通配符 - 单个字符 |
|
||||||
|
| # | 零个或更多的上一个字符(和一般正则表达式里的*一样) |
|
||||||
|
| ## | 一个或更多的上一个字符(和一般正则表达式里的+一样) |
|
||||||
|
*** _regex_words
|
||||||
|
_regex_words函数比_regex_arguments更简单易用。
|
||||||
|
调用_regex_words后的结果可以存在变量里。
|
||||||
|
|
||||||
|
要用_regex_words创建一个定义(specification),你需要提供一个标签,后跟一段描述,后跟一个定义不同词汇的列表。
|
||||||
|
这些定义采用'WORD:DESCRIPTION:SPEC'(即'词汇:描述:定义')的格式,WORD即待补全的词,DESCRIPTION是对应的描述,
|
||||||
|
SPEC可以是由_regex_words创建的另一个变量以指定当前词后的下一个词汇,也可以留空以表示没有更多的词。
|
||||||
|
比如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_regex_words firstword '第一个词' 'word1a:词a:' 'word1b:词b:' 'word1c:词c'
|
||||||
|
#+END_SRC
|
||||||
|
该函数的返回结果将被存入$reply(reply即“回复”、“回应”)数组里,所以我们需要在$reply变化前将结果存进另一个数组里,如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
local -a firstword
|
||||||
|
_regex_words word 'The first word' 'word1a:a word:' 'word1b:b word:' 'word1c:c word'
|
||||||
|
firstword="$reply[@]"
|
||||||
|
#+END_SRC
|
||||||
|
firstword即“第一个词”。
|
||||||
|
然后我们可以把结果用在_regex_arguments里,如:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_regex_arguments _cmd /$'[^\0]##\0'/ "$firstword[@]"
|
||||||
|
_cmd "$@"
|
||||||
|
#+END_SRC
|
||||||
|
注意到我给命令自身也加了模式。
|
||||||
|
|
||||||
|
这里还有个更复杂的词汇,我们调用_regex_words以匹配不同词汇
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
local -a firstword firstword2 secondword secondword2
|
||||||
|
_regex_words word1 '第二个词' 'woo:鄧族' 'hoo:不关我事'
|
||||||
|
secondword=("$reply[@]")
|
||||||
|
_regex_words word2 '另一个第二个词' 'yee:汝' 'haa:很搞笑!'
|
||||||
|
secondword2=("$reply[@]")
|
||||||
|
_regex_words commands '第一个词' 'foo:做foo' 'man:yeah man' 'chu:at chu' # 译注:作者在自嗨,at chu除了比较像at you外没什么特殊意义
|
||||||
|
firstword=("$reply[@]")
|
||||||
|
_regex_words word4 '另一个第一个词' 'boo:吓死某人:$secondword' 'ga:嘤嘤嘤:$secondword'\
|
||||||
|
'loo:上厕所:$secondword2'
|
||||||
|
firstword2=("$reply[@]")
|
||||||
|
|
||||||
|
_regex_arguments _hello /$'[^\0]##\0'/ "${firstword[@]}" "${firstword2[@]}"
|
||||||
|
_hello "$@"
|
||||||
|
#+END_SRC
|
||||||
|
在这个例子中第一个词可以是"foo"、"man"、"chu"、"boo"、"ga"或"loo"。
|
||||||
|
如果第一个词是"boo"或"ga",那下一个词可以是"woo"或"hoo",
|
||||||
|
而如果第一个词是"loo"则第二个词可以是"yee"或"haa",其它情况下没有第二个词。
|
||||||
|
|
||||||
|
_ip函数是_regex_words的一个好用例。
|
||||||
|
** 用_values、_sep_parts和_multi_parts实现复杂补全
|
||||||
|
_values、_sep_parts和_multi_parts可以单独使用,也可以作为_alternative、_arguments或_regex_arguments定义里的ACTION。可以看看下面的例子。
|
||||||
|
查阅[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][官方文档]]以了解更多信息。
|
||||||
|
|
||||||
|
空格分隔的mp3文件列表:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_values 'mp3文件' ~/*.mp3
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
逗号分隔的会话id列表:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_values -s , '会话id' "${(uonzf)$(ps -A o sid=)}"
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
补全foo@news:woo、foo@news:laa或bar@news:woo等:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_sep_parts '(foo bar)' @ '(news ftp)' : '(woo laa)'
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
补全MAC地址,一次补全一个字节:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_multi_parts : '(00:11:22:33:44:55 00:23:34:45:56:67 00:23:45:56:67:78)'
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** 用compadd直接添加补全词
|
||||||
|
你可以使用内置的compadd函数增加补全词,以获得更细致的控制。
|
||||||
|
这个函数有各种选项控制如何显示补全以及补全时如何替换命令行上的文字。
|
||||||
|
阅读[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][官方文档]]以获得更多细节。
|
||||||
|
这里我只给出几个简单的示例。
|
||||||
|
|
||||||
|
向补全列表里加入若干词汇:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
compadd foo bar blah
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
同上但显示注释:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
compadd -X '一些注释' foo bar blah
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
同上但在补全前自动插入"what_"前缀
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
compadd -P what_ foo bar blah
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
同上但补全后自动插入"_todo"后缀:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
compadd -S _todo foo bar blah
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
同上但在后缀后打空格时自动移除"_todo"后缀:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
compadd -P _todo -q foo bar blah
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
向补全数组$wordsarray(wordsarray即“词数组”)加入词汇
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
compadd -a wordsarray
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* 测试与debug
|
||||||
|
重新加载补全函数:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
> unfunction _func
|
||||||
|
> autoload -U _func
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
这些函数会提供有用的信息。
|
||||||
|
如果默认按键没有用,你可以尝试Alt+x然后再输入命令名。
|
||||||
|
| 函数 | 默认按键 | 作用 |
|
||||||
|
|-----------------+--------------------+----------------------------------------------------------------|
|
||||||
|
| _complete_help | Ctrl+x h | 在当前光标位置补全时显示有关上下文名称、标签和补全函数的信息 |
|
||||||
|
| _complete_help | Alt+2 Ctrl+x h | 同上但显示更多信息 |
|
||||||
|
| _complete_debug | Ctrl+x ? | 执行正常补全,但跟踪补全系统执行的shell命令并存入一个临时文件 |
|
||||||
|
* 踩坑了吧 (需要小心的东西)
|
||||||
|
记得在补全函数的文件开头加那行#compdef
|
||||||
|
|
||||||
|
_arguments或_regex_arguments的定义中要使用正确的引号:
|
||||||
|
如果定义中有变量要展开,用双引号,其它情况用单引号,
|
||||||
|
并且记得在ITEM(项目)描述处用不同的引号。(译注:见[[#动作Actions][动作(Actions)]]章节)
|
||||||
|
|
||||||
|
_arguments、_alternative、_regex_arguments等的定义处要在正确的地方使用正确数量的冒号“:”。
|
||||||
|
|
||||||
|
使用_regex_arguments时要记得在开头写匹配命令的模式(不需要加入匹配动作(action))。
|
||||||
|
|
||||||
|
记得在_regex_arguments的任何PATTERN(模式)参数后加上null字符$'\0'
|
||||||
|
* 小贴士
|
||||||
|
有时一个子命令后只会跟一个选项,这时zsh会在tab在子命令后按下时自动补全。如果你想要在补全前先列出选项和描述,
|
||||||
|
你可以向ACTION(动作)加入另一个空选项(比如\:),如':TAG:DESCRIPTION:((opt1\:"opt1描述" \:))'
|
||||||
|
注意这只对在定义参数中使用ACTION的工具函数(_arguments、_regex_arguments等)有效。
|
||||||
|
|
||||||
|
* 其它资源
|
||||||
|
[[https://wikimatze.de/writing-zsh-completion-for-padrino/][这]]是个展示_arguments函数的基本使用方法的教程,短小精悍,
|
||||||
|
而[[https://web.archive.org/web/20190411104837/http://www.linux-mag.com/id/1106/][这]]是_arguments函数的稍稍更进阶的教程。
|
||||||
|
[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][这]]是zshcompsys手册页(man page)。
|
||||||
Loading…
Reference in New Issue