Compare commits

...

38 Commits

Author SHA1 Message Date
F.B. 0a355edd50
Merge 5359bbf0e7 into 922abfe707 2025-07-17 10:19:46 +05:30
Shohei YOSHIDA 922abfe707
Merge pull request #1140 from zsh-users/update-completions
Update completions cmake, node, xsel
2025-07-11 11:28:27 +09:00
Shohei YOSHIDA ed034970c2
Update xsel completion v1.2.1 2025-07-10 12:51:27 +09:00
Shohei YOSHIDA fe11bbe8b0
Update node completion v24.4.0 2025-07-10 12:41:55 +09:00
Shohei YOSHIDA 1ee071125e
Update cmake completion version 3.31 2025-07-10 11:56:56 +09:00
Shohei YOSHIDA 6ba54212d0
Merge pull request #1139 from zsh-users/update-shell-check
Update shellcheck completion v0.10.0
2025-07-09 11:56:48 +09:00
Shohei YOSHIDA 932c16fd0e
Update shellcheck completion 2025-07-08 11:35:41 +09:00
Shohei YOSHIDA e07f6fb780
Merge pull request #1137 from JesseAye/f2b-regex
Add fail2ban-regex options and parameters
2025-06-12 10:16:04 +09:00
Jesse Ayala d326bdc241
Fix error when no matching files in working dir
If there are no files in the current working directory, zparse opts complains with "missing argument for option: -g"

Co-authored-by: Shohei YOSHIDA <syohex@gmail.com>
2025-06-11 20:17:41 -04:00
Jesse 335af5c72d Add fail2ban-regex options and parameters 2025-06-09 00:40:28 -04:00
Shohei YOSHIDA c29efd0bc3
Merge pull request #1136 from zsh-users/update-cppcheck
Update cppcheck completion to version 2.17.1
2025-06-01 09:25:57 +09:00
Shohei YOSHIDA 4625071e98
Update cppcheck completion to version 2.17.1 2025-05-29 22:03:43 +09:00
Shohei YOSHIDA 21789376b8
Merge pull request #1135 from zsh-users/update-completions
Update kak and clang utility completions
2025-05-25 11:16:50 +09:00
Shohei YOSHIDA a221bd2653
Update clang utilities 2025-05-23 13:33:49 +09:00
Shohei YOSHIDA ab95699400
Update UI type name list 2025-05-23 13:33:08 +09:00
Shohei YOSHIDA 99d000d880
Merge pull request #1134 from zsh-users/update-completions
Update shallow-backup, ufw completions
2025-05-17 21:42:55 +09:00
Shohei YOSHIDA d1469c6e4f
Update ufw completion 2025-05-16 17:44:28 +09:00
Shohei YOSHIDA 77cad16cc7
Update shallow-backup completion 2025-05-16 16:30:13 +09:00
Shohei YOSHIDA 8af769e5f1
Format 2025-05-16 16:24:21 +09:00
Shohei YOSHIDA 67e6bdbc3c
Update setcap completion flags 2025-05-16 16:24:04 +09:00
Shohei YOSHIDA 98dd809126
Merge pull request #1133 from zsh-users/update-nodejs
Update node completion for version 24.0.0
2025-05-08 11:24:25 +09:00
Shohei YOSHIDA c4fca6525a
Update node completion for version 24.0.0 2025-05-07 11:25:19 +09:00
Shohei YOSHIDA 4f6441f9ee
Merge pull request #1131 from zsh-users/update-pre-commit
Update pre-commit completion to version 4.2.0
2025-04-28 09:57:22 +09:00
Shohei YOSHIDA 4e0cdee2e7
Update pre-commit completion to version 4.2.0 2025-04-22 15:19:11 +09:00
fishBone000 5359bbf0e7
Forgot to change ToC 2024-09-18 06:07:34 +00:00
fishBone000 a3e89f7c56
Reread to make the doc more fluent 2024-09-18 06:06:48 +00:00
fishBone000 cf57a3266c
Try to fix ToC 2024-09-18 04:52:48 +00:00
fishBone000 41896a6013
Finish most TODOs 2024-09-18 04:43:01 +00:00
fishBone000 0d8667bb6a
Fix Table of Contents
I forgot to change it
2024-09-18 04:17:10 +00:00
fishBone000 79c6d1715f
Finish Other resources 2024-09-18 04:15:31 +00:00
fishBone000 f5e58a5ca7
Finish Tips 2024-09-18 04:12:15 +00:00
fishBone000 6c8cd1b111
Finish Gotchas (things to look out for) 2024-09-18 04:01:09 +00:00
fishBone000 eb711299c5
Finish Testing & debugging 2024-09-18 03:53:13 +00:00
fishBone000 d71c3c84cc
Finish Writing your own completion code 2024-09-18 03:43:52 +00:00
fishBone000 c3f1f7748d
Finish Getting started 2024-09-17 07:40:59 +00:00
fishBone000 45fd6f398a
Fix document file extension 2024-09-17 07:15:24 +00:00
fishBone000 26b538f012
Finish Intro 2024-09-17 07:13:14 +00:00
fishBone000 fd43209f3a
Beginning of zh_cn translation 2024-09-17 06:37:21 +00:00
16 changed files with 791 additions and 203 deletions

View File

@ -24,7 +24,7 @@
# Description
# -----------
#
# Completion script for clang-check v15.0.2 (https://clang.llvm.org/docs/ClangCheck.html)
# Completion script for clang-check v20.1.2 (https://clang.llvm.org/docs/ClangCheck.html)
#
# ------------------------------------------------------------------------------
# Authors
@ -37,6 +37,8 @@
_arguments \
'(- *)--help[Display available options]' \
'(- *)--help-hidden[Display available more options]' \
'(- *)--help-list[Display list of available options]' \
'(- *)--help-list-hidden[Display list of more available options]' \
'(- *)--version[Display the version of this program]' \
'--analyze[Run static analysis engine]' \
'--analyzer-output-path=[Write output to file]: :_files' \
@ -49,6 +51,8 @@ _arguments \
'--fix-what-you-can[Apply fix-it advice even in the presence of unfixable errors]' \
'--fixit[Apply fix-it advice to the input source]' \
'-p[Build directory where compile_commands.json is]: :_files -/' \
'--print-all-options[Print all option values after command line parsing]' \
'--print-options[Print non-default options after command line parsing]' \
'--syntax-tree-dump[dump the syntax tree]' \
'--tokens-dump[dump the preprocessed tokens]' \
'*: :_files'

View File

@ -24,7 +24,7 @@
# Description
# -----------
#
# Completion script for clang-format v15.0.2 (https://clang.llvm.org/docs/ClangFormat.html)
# Completion script for clang-format v20.1.2 (https://clang.llvm.org/docs/ClangFormat.html)
#
# ------------------------------------------------------------------------------
# Authors
@ -41,24 +41,31 @@ _arguments \
'(- *)--help-hidden[Display available more options]' \
'(- *)--help-list[Display list of available options]' \
'(- *)--help-list-hidden[Display list of more available options]' \
'--Wclang-format-violations[Warnings about individual formatting changes needed]' \
'--Werror=[If set, changes formatting warnings to errors]' \
'*--Wno-error=[If set, do not error out on the specified warning type]:warn' \
'--assume-filename=[Set filename used to determine the language and to find .clang-format file]: :_files' \
'--cursor=[The position of the cursor when invoking clang-format from an editor integration]:pos' \
'(-n --dry-run)'{-n,--dry-run}'[If set, do not actually make the formatting changes]' \
'--dump-config[Dump configuration options to stdout and exit]' \
'--fail-on-incomplete-format[If set, fail with exit code 1 on incomplete format]' \
'--fallback-style=[The name of the predefined style used as a fallback]: :'"($styles)" \
'--ferror-limit=[Set the maximum number of clang-format errors to emit before stopping]:limit' \
'*--files=[Provide a list of files to run clang-format]: :_files' \
'--fno-color-diagnostics[If set, not to print diagnostics in color]' \
'-i[Inplace edit files, if specified]' \
'--length=[Format a range of this length(in bytes)]:bytes' \
'--lines=[format a range of lines]:format' \
'--list-ignored[List ignored files]' \
'--offset=[Format a range starting at this byte offset]' \
'--output-replacements-xml[Output replacements as XML]' \
'--print-all-options[Print all option values after command line parsing]' \
'--print-options[Print non default options after command line parsing]' \
'--qualifier-alignment=[If set, overrides the qualifier alignment style determined by the QualifierAlignment style flag]' \
'--sort-includes[If set, overrides the include sorting behavior determined by the SortIncludes style flag]' \
'--style=[Set coding style]: :'"($styles)" \
'--verbose[If set, show the list of processed files]' \
'(- *)--version[Display the version of this program]' \
'*: :_files'
# Local Variables:

View File

@ -41,12 +41,14 @@ _arguments \
'(- *)--help-hidden[Display available more options]' \
'(- *)--help-list[Display list of available options]' \
'(- *)--help-list-hidden[Display list of more available options]' \
'--allow-no-checks[Allow empty enabled checks]' \
'--checks=[Comma-separated list of globs with optional "-" prefix]:checks' \
'--config=[Specifies a configuration in YAML/JSON format]:conf' \
'--config-file=[Specify the path of .clang-tidy or custom config-file]: :_files' \
'--dump-config[Dumps configuration in the YAML format to stdout]' \
'--enable-check-profile[Enable per-check timing profiles, and print a report to stderr]' \
'--enable-module-headers-parsing[Enable preprocessor-level module header parsing for C++20 and above]' \
'--exclude-header-filter=[Regular expression of headers to exclude diagnostics from]:filter' \
'--explain-config[For each enabled check explains, where it is enabled]' \
'--export-fixes=[YAML file to store suggested fixes in]: :_files' \
'*--extra-arg[Additional argument to append to the compiler command line]:arg' \
@ -54,16 +56,19 @@ _arguments \
'--fix[Apply suggested fixes]' \
'--fix-errors[Apply suggested fixes even if compilation errors were found]' \
'--fix-notes[If a warning has no fix, but a single fix can be found through an associated diagnostic node, apply the fix]' \
'--format-style=[Style for formatting code around applied fixes]: :(llvm google webkit mozilla)' \
'--format-style=[Style for formatting code around applied fixes]: :(none file llvm google webkit mozilla)' \
'--header-filter=[Regular expression matching the names of the headers to output diagnostics from]:regexp' \
'--line-filter=[List of files with line ranges to filter the warnings]' \
'(- *)--list-checks[List all enabled checks and exit]' \
'--load=[Load the specified plugin]: :_files' \
'-p[Build directory where compile_commands.json is]: :_files -/' \
'--print-all-options[Print all option values after command line parsing]' \
'--print-options[Print non default options after command line parsing]' \
'--quiet[Run clang-tidy in quiet mode]' \
'--store-check-profile=[These per-TU profiles are instead stored as JSON]:prefix' \
'--system-headers[Display the errors from system headers]' \
'--use-color[Use colors in diagnostics]' \
'(- *)--version[Display the version of this program]' \
'--verify-config[Check the config files to ensure each check and option is recognized]' \
'--vfsoverlay=[Overlay the virtual filesystem described by file over the real file system]: :_files' \
'--warnings-as-errors=[Upgrades warning to errors]:check' \

View File

@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for CMake 3.25.0 (https://cmake.org).
# Completion script for CMake 3.31.0 (https://cmake.org).
#
# -------------------------------------------------------------------------
# Authors
@ -77,6 +77,7 @@ local -a cmake_build_options=(
'--preset=[Specify a configure preset]:preset:_cmake_presets'
'--list-presets[List available presets]'
'--workflow[Run a workflow preset]'
'-E[CMake command mode]:command:_cmake_command_help'
@ -94,6 +95,7 @@ local -a cmake_build_options=(
'--graphviz=[Generate graphviz of dependencies, see CMakeGraphVizOptions.cmake for more]:graphviz output:_files'
'--system-information[Dump information about this system]::system information output:_files'
'--print-config-dir[Print CMake config directory for user-wide FileAPI queries]'
'--log-level=[Set the verbosity of messages from CMake files]:log level:(ERROR WARNING NOTICE STATUS VERBOSE DEBUG TRACE)'
'--log-context[Prepend log messages with context, if given]'
@ -101,6 +103,8 @@ local -a cmake_build_options=(
'--debug-trycompile[Do not delete the try_compile build tree. Only useful on one try_compile at a time]'
'--debug-output[Put cmake in a debug mode]'
'--debug-find[Put cmake find in a debug mode]'
'--debug-find-pkg=[Limit cmake debug-find to the comma-separated list of packages]:packages'
'--debug-find-var=[Limit cmake debug-find to the comma-separated list of result variables]:variables'
'(--trace-expand)--trace[Put cmake in trace mode]'
'(--trace)--trace-expand[Put cmake in trace mode with variable expansion]'

View File

@ -40,7 +40,7 @@
# Notes
# -----
#
# Created for Cppcheck version 2.12 (https://github.com/danmar/cppcheck)
# Created for Cppcheck version 2.17.1 (https://github.com/danmar/cppcheck)
#
# ------------------------------------------------------------------------------
@ -50,13 +50,17 @@ _cppcheck_files() {
_cppcheck() {
local check_ids='(all warning style performance portability information unusedFunction missingInclude)'
local platforms='(unix32 unix64 win32A win32W win64 avr8 elbrus-e1cp pic8 pic8-enhanced pic16 mips32 native unspecified)'
local coding_standards='(normal autosar cert-c-2016 cert-cpp-2016 misra-c-2012 misra-c-2023 misra-cpp-2008 misra-cpp-2023)'
_arguments \
"--addon=[Execute addon]" \
"--addon-python=[Specify the python interpreter]: :_files" \
"--cppcheck-build-dir=[Analysis output directory]:directory:_files -/" \
"--check-config[Check cppcheck configuration]" \
"--check-level=[Configure how much valueflow analysis you want]:level:(reduced normal exhaustive)" \
"--check-library[Show information when library files have incomplete info]" \
"--checkers-report=[Write a report of all the active checkers to the given file]:file:_files" \
"--clang=[Use clang parser instead of the builtin Cppcheck parser]: :_files" \
"--config-exclude=[Path to be excluded from configuration checking]:directory:_files -/" \
"--config-exclude-files=[A file that contains a list of config-excludes]:file:_files" \
@ -72,8 +76,10 @@ _cppcheck() {
"--exitcode-suppressions=[Used when certain messages should be displayed but should not cause a non-zero exitcode]:_files" \
"*--file-filter=[Analyze only those files matching the given filter str]:filter" \
"--file-list=[Specify the files to check in a text file]:_files" \
'(-f --force)'{-f,--force}"[Force checking of all configurations in files]" \
'(- 1 *)'{-h,--help}"[Print this help]" \
"(-f --force)"{-f,--force}"[Force checking of all configurations in files]" \
"(--fsigned-char --funsigned-char)--fsigned-char[Treat char type as signed]" \
"(--fsigned-char --funsigned-char)--funsigned-char[Treat char type as unsigned]" \
"(- 1 *)"{-h,--help}"[Print this help]" \
"-I[A file that contains a list of config-excludes]:directory:_files -/" \
"--include-file=[Specify directory paths to search for included header files in a text file]:file:_files" \
"--include=[Force inclusion of a file before the checked file]:file:_files" \
@ -83,26 +89,34 @@ _cppcheck() {
"-j[Number of threads to do the checking simultaneously]::num" \
"-l[No new threads should be started if the load average is exceeds this value]::load_avg" \
{-x,--language=}"[Forces cppcheck to check all files as the given language]:language:(c c++)" \
"--library=[Load config file that contains information about types and functions]:config:_files" \
"--max-configs=[Maximum number of configurations to check in a file]" \
"--max-ctu-depth=[Maximum depth in whole program analysis]:num" \
"--output-file=[File to save results]:file:_files" \
"--output-format=[Specify the output format]:format:(text sarif xml)" \
"--platform=[Specified platform specific types and sizes]:platform:$platforms" \
"--plist-output=[Generate Clang-plist output files in folder]:_files" \
"--project=[Run Cppcheck on project]:file:_files" \
"--project-configuration=[Limit the configuration cppcheck should check]:configuration" \
"--platform=[Set platform specific types and sizes]:platforms:(unix32 unix64 win32A win32W win64 avr8 elbrus-e1cp pic8 pic8-enhanced pic16 mips32 native unspecified)" \
'(-q --quiet)'{-q,--quiet}"[Do not show progress reports]" \
"(-q --quiet)"{-q,--quiet}"[Do not show progress reports]" \
{-rp,--relative-paths}"=[Use relative paths in output (separated with ;)]:_files" \
"--report-progress[Report progress messages while checking a file]" \
"--report-type=[Add guideline and classification fields for specified coding standard]:standard:$coding_standards" \
"--rule=[Match regular expression]:rule" \
"--rule-file=[Use given rule file]:file:_files" \
"--showtime=[show timing information]:type:(none file file-total summary top5_file top5_summary top5)" \
"--std=[Set standard]:std:(c89 c99 c11 c++03 c++11 c++14 c++17 c++20)" \
"--suppress=[Suppress warnings (format: \[error id\]:\[filename\]:\[line\])]" \
"--suppressions-list=[Suppress warnings listed in the file]:_files" \
"--suppress-xml=[Suppress warnings listed in a xml file]:_files" \
"--template=[Format the error messages]" \
"--template-location=[Format the error message location]" \
"*-U[Undefine preprocessor symbol]:symbol" \
"(-v --verbose)"{-v,--verbose}"[Output more detailed error information]" \
"--version[Print out version number]" \
"--xml[Write results in xml format to stderr]" \
'*: :_cppcheck_files'
"*: :_cppcheck_files"
}
_cppcheck "$@"

57
src/_fail2ban-regex Normal file
View File

@ -0,0 +1,57 @@
#compdef fail2ban-regex
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for fail2ban-regex (https://www.fail2ban.org/).
# Environment:
# Linux 6.14.10-arch1-1 x86_64 GNU/Linux
# zsh 5.9 (x86_64-pc-linux-gnu)
# fail2ban 1.1.0-7
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Jesse Ayala <jesserayala95@gmail.com>
#
# ------------------------------------------------------------------------------
integer NORMARG
_arguments -A "-*" -n \
'--version[show program''s version number]' \
'(-h --help)'{-h,--help}'[display the help message]' \
'(-c --config)'{-c,--config=}'[set alternate config directory]:directory:_files -/' \
'(-d --datepattern)'{-d,--datepattern=}'[set custom pattern used to match date/times]:DATEPATTERN' \
'(--timezone= --TZ=)'{--timezone=,--TZ=}'[set time-zone used by convert time format]:TIMEZONE' \
'(-e --encoding=)'{-e,--encoding=}'[use different encoding from system locale]:ENCODING' \
'(-r --raw)'{-r,--raw}'[raw hosts,don''t resolve dns]' \
'--usedns=[DNS specified replacement of tags <HOST> in regexp]::((yes\:matches all form of hosts no\:IP addresses only))' \
'(-L --maxlines=)'{-L,--maxlines}'[maxlines for multi-line regex]:MAXLINES' \
'(-m --journalmatch=)'{-m,--journalmatch=}'[journalctl style matches overriding filter file; "systemd-journal" only]:JOURNALMATCH' \
'(-l --log-level=)'{-l,--log-level}'[log level for the Fail2Ban logger to use]:LOG_LEVEL' \
'-V[get version in machine-readable short format]' \
'--verbosity=[set numerical level of verbosity]:(0 1 2 3 4)' \
'(--verbose-date --VD)'{--verbose-date,--VD}'[verbose date patterns/regex in output]' \
'(-D --debuggex)'{-D,--debuggex}'[produce debuggex.com urls for debugging there]' \
'--no-check-all[disable check for all regexes]' \
'(-o --out)'{-o,--out}'[set token to print failure information only (row, id, ip, msg, host, ip4, ip6, dns, matches, ...)]:out' \
'--print-no-missed[do not print any missed lines]' \
'--print-no-ignored[do not print any ignored lines]' \
'--print-all-matched[print all matched lines]' \
'--print-all-missed[print all missed lines, no matter how many]' \
'--print-all-ignored[print all ignored lines, no matter how many]' \
'(-t --log-traceback)'{-t,--log-traceback}'[enrich log-messages with compressed tracebacks]' \
'--full-traceback[enrich log-messages with full, uncompressed tracebacks]:' \
'1:file:_files -g \*.log' \
'2:file:_files -W /etc/fail2ban/filter.d -g \*\.\(conf\|local\)' \
'3:file:_files -W /etc/fail2ban/filter.d -g \*\.\(conf\|local\)'
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: set et sw=2 ts=2 ft=zsh:

View File

@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for kak 2022.10.31 (https://github.com/mawww/kakoune)
# Completion script for kak 2024.05.18 (https://github.com/mawww/kakoune)
#
# ------------------------------------------------------------------------------
# Authors
@ -57,7 +57,7 @@ _kak() {
"-f[enter in 'filter mode':select the whole file, then execute keys]:keys" \
'-i[backup the files on which a filter is applied using the given suffix]:suffix' \
'-q[in filter mode, do not print any errors]' \
'-ui[set the type of user interface to use (ncurses, dummy, or json)]:ui_type:(ncurses dummy json)' \
'-ui[set the type of user interface to use (terminal, dummy, or json)]:ui_type:(terminal dummy json)' \
'-l[list existing sessions]:session_id:_kak_sessions' \
'-clear[clear dead sessions]' \
'-debug[initial debug option value]:arg' \

View File

@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for Node.js v23.8.0 (https://nodejs.org)
# Completion script for Node.js v24.4.0 (https://nodejs.org)
#
# ------------------------------------------------------------------------------
# Authors
@ -49,7 +49,7 @@ _node_files() {
fi
done
_files -g "*.(js|mjs)"
_files -g "*.(js|mjs|ts|mts)"
}
_node_args() {
@ -93,6 +93,7 @@ _arguments -C \
'--cpu-prof-name=[file name of the V8 profile generated with --cpu-prof]: :_files' \
'--diagnostic-dir=[set dir for all output files(default: current working directory)]:dir:_files -/' \
'--disable-proto=[disable Object.prototype.__proto__]:mode:(delete throw)' \
'--disable-sigusr1[disable inspector thread to be listening for SIGUSR1 signal]' \
'*--disable-warning=[silence specific process warnings]:warn type' \
'--disable-wasm-trap-handler[disable trap-handler-based WebAssembly bound checks]' \
'--disallow-code-generation-from-strings[disallow eval and friends]' \
@ -105,7 +106,8 @@ _arguments -C \
'*--env-file-if-exists=[set environment variables from supplied file if exists]:envfile:_files' \
'(- 1 *)'{-e,--eval}'[evaluate script]:inline JavaScript' \
'--experimental-addon-modules[enable experimental import support for addons]' \
'--experimental-async-context-frame[improve AsyncLocalStorage performance with AsyncContextFrame]' \
'--experimental-config-file=[set config file from supplied file]:file:_files' \
'--experimental-default-config-file[set config file from default config file]' \
'--experimental-eventsource[enable experimental EventSource API]' \
'--experimental-import-meta-resolve[experimental ES Module import.meta.resolve() support]' \
'(--loader --experimental-loader)'{--loader,--experimental-loader}'=[Specify the module of a custom ECMAScript Module loader]: :_files' \
@ -150,6 +152,8 @@ _arguments -C \
'--no-experimental-global-navigator[expose experimental Navigator API on the global scope]' \
'--no-experimental-repl-await[disable experimental await keyword support in REPL]' \
'--no-experimental-require-module[allow loading synchronous ES Modules in require()]' \
'--no-experimental-sqlite[disable experimental node sqlite module]' \
'--no-experimental-strip-types[disable experimental type-stripping for TypeScript files]' \
'--no-experimental-websocket[experimental WebSocket API (currently set)]' \
'--no-extra-info-on-fatal-exception[hide extra information on fatal exception that causes exit]' \
'--no-force-async-hooks-checks[disable checks for async_hooks]' \
@ -228,6 +232,7 @@ _arguments -C \
'(- 1 *)--v8-options[print v8 command line options]' \
"--v8-pool-size=[set v8's thread pool size]:number" \
"--watch[run in watch mode]" \
'--watch-kill-signal=[kill signal to send to the process on watch mode restarts]:signal:_signals -s' \
"--watch-path=[path to watch]: :_node_files" \
'--watch-preserve-output[preserve outputs on watch mode restart]' \
'--zero-fill-buffers[automatically zero-fill all newly allocated Buffer and SlowBuffer instances]' \

View File

@ -3,7 +3,7 @@
# Description
# -----------
#
# Completion script for pre-commit (https://github.com/pre-commit/pre-commit/).
# Completion script for pre-commit 4.2.0 (https://github.com/pre-commit/pre-commit/).
# Modified from rejected https://github.com/pre-commit/pre-commit/pull/2506
#
# ------------------------------------------------------------------------------
@ -15,7 +15,7 @@
# ------------------------------------------------------------------------------
_pre_commit_commands() {
local _commands=(
local commands=(
"autoupdate:Auto-update pre-commit config to the latest repos' versions"
"clean:Clean out pre-commit files"
"gc:Clean unused cached repos"
@ -30,8 +30,9 @@ _pre_commit_commands() {
"uninstall:Uninstall the pre-commit script"
"validate-config:Validate .pre-commit-config.yaml files"
"validate-manifest:Validate .pre-commit-hooks.yaml files"
"help:Show help for a specific command"
)
_describe 'pre-commit commands' _commands
_describe 'pre-commit commands' commands
}
_pre_commit_options=(
@ -46,6 +47,7 @@ _pre_commit_autoupdate_options=(
"--bleeding-edge[Update to the bleeding edge of 'HEAD' instead of the latest tagged version]"
"--freeze[Store 'frozen' hashes in 'rev' instead of tag names]"
"*--repo[Only update this repository -- may be specified multiple times]:repos:"
{-j,--jobs}"[Number of threads to use]:jobs"
)
_pre_commit_clean_options=(
@ -68,7 +70,7 @@ _pre_commit_init_templatedir_options=(
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
"--no-allow-missing-config[Assume cloned repos should have a 'pre-commit' config]"
"*"{-t,--hook-type}"[which hook type to install]:hook_types:(pre-commit pre-merge-commit pre-push prepare-commit-msg commit-msg post-commit post-checkout post-merge post-rewrite)"
"*"{-t,--hook-type}"[which hook type to install]:hook_types:(commit-msg post-checkout post-commit post-merge post-rewrite pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg)"
":The directory in which to write the hook script.:_files -/"
)
@ -78,7 +80,7 @@ _pre_commit_install_options=(
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
{-f,--overwrite}"[Overwrite existing hooks / remove migration mode]"
"--install-hooks[Whether to install hook environments for all environments in the config file]"
"*"{-t,--hook-type}"[which hook type to install]:hook_types:(pre-commit pre-merge-commit pre-push prepare-commit-msg commit-msg post-commit post-checkout post-merge post-rewrite)"
{-t,--hook-type}"[which hook type to install]:hook_type:(commit-msg post-checkout post-commit post-merge post-rewrite pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg)"
"--allow-missing-config[Hook scripts will permit a missing configuration file]"
)
@ -102,11 +104,13 @@ _pre_commit_run_options=(
{--all-files,-a}"[Run on all the files in the repo]"
"--files[Specific filenames to run hooks on]:files:_files"
"--show-diff-on-failure[When hooks fail, run 'git diff' directly afterward]"
"--hook-stage[The stage during which the hook is fired]:hook_stage:(commit merge-commit prepare-commit-msg commit-msg post-commit manual post-checkout push post-merge post-rewrite)"
"--hook-stage[The stage during which the hook is fired]:hook_stage:(commit-msg post-checkout post-commit post-merge post-rewrite pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg manual)"
"--remote-branch[Remote branch ref used by 'git push']:remote_branch:"
"--local-branch[Local branch ref used by 'git push']:local_branch:"
{--from-ref,--source,-s}"[the original ref in a 'from_ref...to_ref' diff expression]:from_ref:"
{--to-ref,--origin,-o}"[the destination ref in a 'from_ref...to_ref' diff expression]:to_ref:"
"--pre-rebase-upstream[the upstream from which the series was forked]:pre_rebase_upstream"
"--pre-rebase-branch[the branch being rebased and is not set when rebasing the current branch]:pre_rebase_branch"
"--commit-msg-filename[Filename to check when running during 'commit-msg']:commit_msg_filename:"
"--prepare-commit-message-source[Source of the commit message]:prepare_commit_message_source:"
"--commit-object-name[Commit object name]:commit_object_name:"
@ -132,11 +136,13 @@ _pre_commit_try_repo_options=(
{--all-files,-a}"[Run on all the files in the repo]"
"--files[Specific filenames to run hooks on]:files:_files"
"--show-diff-on-failure[When hooks fail, run 'git diff' directly afterward]"
"--hook-stage[The stage during which the hook is fired]:hook_stage:(commit merge-commit prepare-commit-msg commit-msg post-commit manual post-checkout push post-merge post-rewrite)"
"--hook-stage[The stage during which the hook is fired]:hook_stage:(commit-msg post-checkout post-commit post-merge post-rewrite pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg manual)"
"--remote-branch[Remote branch ref used by 'git push']:remote_branch:"
"--local-branch[Local branch ref used by 'git push']:local_branch:"
{--from-ref,--source,-s}"[the original ref in a 'from_ref...to_ref' diff expression]:from_ref:"
{--to-ref,--origin,-o}"[the destination ref in a 'from_ref...to_ref' diff expression]:to_ref:"
"--pre-rebase-upstream[the upstream from which the series was forked]:pre_rebase_upstream"
"--pre-rebase-branch[the branch being rebased and is not set when rebasing the current branch]:pre_rebase_branch"
"--commit-msg-filename[Filename to check when running during 'commit-msg']:commit_msg_filename:"
"--prepare-commit-message-source[Source of the commit message]:prepare_commit_message_source:"
"--commit-object-name[Commit object name]:commit_object_name:"
@ -153,7 +159,7 @@ _pre_commit_uninstall_options=(
"(- : *)"{-h,--help}"[show this help message and exit]"
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
"*"{-t,--hook-type}"[which hook type to uninstall]:hook_types:(pre-commit pre-merge-commit pre-push prepare-commit-msg commit-msg post-commit post-checkout post-merge post-rewrite)"
"*"{-t,--hook-type}"[which hook type to uninstall]:hook_types:(commit-msg post-checkout post-commit post-merge post-rewrite pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg)"
)
_pre_commit_validate_config_options=(

View File

@ -42,6 +42,10 @@ _setcap() {
local curcontext=$curcontext state line expl ret=1
_arguments -C -s \
'-r[remove capability from file]' \
'--license[display the license info]' \
'-f[force setting even when the capability is invalid]' \
'-h[show help message and exit]' \
'-v[verify that the specified capabilities are currently associated with the file]' \
'-n[set the file capability for use only in a user namespace with this root user ID owner]:rootuid' \
'-q[make the program less verbose in its output]' \

View File

@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for shallow-backup: https://github.com/alichtman/shallow-backup
# Completion script for shallow-backup v6.4: https://github.com/alichtman/shallow-backup
#
# ------------------------------------------------------------------------------
# Authors
@ -38,30 +38,30 @@
#
# ------------------------------------------------------------------------------
_shallow-backup() {
_arguments \
'(- 1 *)'{-h,--help}'[Show help and exit]' \
'(- 1 *)'{-v,--version}'[Print version]' \
'--add-dot[Add a dotfile or dotfolder to config by path]:PATH:_files' \
'--backup-all[Full back up]' \
'--backup-configs[Back up app config files]' \
'--backup-dots[Back up dotfiles]' \
'--backup-fonts[Back up installed fonts]' \
'--backup-packages[Back up package libraries]' \
'--delete-config[Delete config file]' \
'--destroy-backup[Delete backup directory]' \
'--dry-run[Do not backup or reinstall any files, just give verbose output]' \
'--new-path[Input a new back up directory path]:PATH:_files -/' \
'--no-new-backup-path-prompt[Skip setting new back up directory path prompt]' \
'--no-splash[Do not display splash screen]' \
'--reinstall-all[Full reinstallation]' \
'--reinstall-configs[Reinstall configs]' \
'--reinstall-dots[Reinstall dotfiles and dotfolders]' \
'--reinstall-fonts[Reinstall fonts]' \
'--reinstall-packages[Reinstall packages]' \
'--remote[Set remote URL for the git repo]':url \
'--show[Display config file]'
_arguments \
'(- 1 *)'{-h,--help}'[Show help and exit]' \
'(- 1 *)'{-v,--version}'[Print version]' \
'--add-dot[Add a dotfile or dotfolder to config by path]:PATH:_files' \
'--backup-all[Full back up]' \
'--backup-configs[Back up app config files]' \
'--backup-dots[Back up dotfiles]' \
'--backup-fonts[Back up installed fonts]' \
'--backup-packages[Back up package libraries]' \
'--delete-config[Delete config file]' \
'--destroy-backup[Delete backup directory]' \
'--dry-run[Do not backup or reinstall any files, just give verbose output]' \
'--new-path[Input a new back up directory path]:PATH:_files -/' \
'--no-new-backup-path-prompt[Skip setting new back up directory path prompt]' \
'--no-splash[Do not display splash screen]' \
'--reinstall-all[Full reinstallation]' \
'--reinstall-configs[Reinstall configs]' \
'--reinstall-dots[Reinstall dotfiles and dotfolders]' \
'--reinstall-fonts[Reinstall fonts]' \
'--reinstall-packages[Reinstall packages]' \
'--remote[Set remote URL for the git repo]':url \
'--edit[Open config file in $EDITOR]' \
'--show[Display config file]'
}
_shallow-backup

View File

@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for shellcheck (https://github.com/koalaman/shellcheck)
# Completion script for shellcheck v0.10.0 (https://github.com/koalaman/shellcheck)
#
# ------------------------------------------------------------------------------
# Authors
@ -43,12 +43,14 @@ _arguments \
{-C,--color=}'[specify color]:color:(auto always never)' \
{-i,--include=}'[consider only given types of warnings]:error code' \
{-e,--exclude=}'[exclude given types of warnings]:error code' \
'--extended-analysis=[perform dataflow analysis]:bool:(true false)' \
{-f,--format=}'[specify output format]:format:(checkstyle diff gcc json json1 quiet tty)' \
'--list-optional[list checks disabled by default]' \
"--norc[don't look for .shellcheckrc files]" \
'--rcfile=[specify configuration file over searching for one]:rcfile:_files' \
{-o,--enable=}"[give list of optional checks to enable (or 'all')]:error code" \
{-P,--source-path=}'[specify path when looking for sourced files]:_files -/' \
{-s,--shell=}'[specify dialect]:dialect:(sh bash dash ksh)' \
{-s,--shell=}'[specify dialect]:dialect:(sh bash dash ksh busybox)' \
{-S,--severity=}'[specify minimum severity of errors to consider]:severity:(error warning info style)' \
{-V,--version}'[print version information]' \
{-W,--wiki-link-count=}'[specify number of wiki links to show, when applicable]:number' \

View File

@ -35,7 +35,7 @@
# -------
#
# * Bruno Michel (https://github.com/nono)
# * Shoehi Yoshida (https://github.com/nono)
# * Shohei Yoshida (https://github.com/nono)
#
# ------------------------------------------------------------------------------
@ -76,78 +76,78 @@ _showoff() {
'*:: :->args' \
&& ret=0
case $state in
(args)
case $line[1] in
(add|new)
_arguments \
'(-d --dir)'{-d,--dir}='[Slide dir (where to put a new slide file)]:directory:_files -/' \
'(-n --name)'{-n,--name}='[Slide name (name of the new slide file)]:basename' \
{-s,--source}='[Include code from the given file as the slide body]:file:_files' \
'(-t --style --type)'{-t,--style,--type}='[Slide Type/Style (default: title)]:style' \
'(-u --nonumber)'{-u,--nonumber}"[Don't number the slide, use the given name verbatim]" \
'1:title' && ret=0
;;
(create|init)
_arguments \
'(-d --slidedir)'{-d,--slidedir}='[Sample slide directory name (default: one)]:arg' \
'(-n --nosamples)'{-n,--nosamples}="[Don't create sample slides]" \
'1:dir_name' && ret=0
;;
(help)
_arguments \
'-c[List commands one per line, to assist with shell completion]' \
'1: :_showoff_help' && ret=0
;;
(heroku)
_arguments \
'(-f --force)'{-f,--force}'[force overwrite of existing Gemfile, .gems and config.ru files if they exist]' \
'(-p --password)'{-p,--password}='[add password protection to your heroku site(default: none)]' \
'1:heroku_name' && ret=0
;;
(info)
_arguments \
'(-f --file)'{-f,--file}='[alternate json filename]: :_files -g "*.json"' \
'(-j --json)'{-j,--json}'[render output as json]' \
&& ret=0
;;
(pdf|static)
_arguments \
'(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \
'(-l --lang --language --locale)'{-l,--lang,--language,--locale}'[Language code to generate(default: none)]' \
'1:name' \
&& ret=0
;;
(serve)
_arguments \
'(-S --standalone)'{-S,--standalone}'[Run in standalone mode with no audience interaction]' \
'(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \
'--git_branch=[Branch of git repository to use(default: none)]:branch' \
'--git_path=[Path of the presentation within the git repository(default: none)]:path' \
'(-h --host)'{-h,--host}='[Host or ip to run on(default: 0.0.0.0)]' \
'--nocache[Disable content caching]'\
'--nosleep[Prevent the computer from sleeping during your presentation]' \
'(-p --port)'{-p,--port}='[Port on which to run(default: 9090)]' \
'(-r --review)'{-r,--review}'[Enable code review]'\
'(-s --ssl)'{-s,--ssl}'[Run via HTTPS]' \
'--ssl_certificate=[Path to SSL certificate]: :_files' \
'--ssl_private_key=[Path to SSL private key]: :_files' \
'(-u --url --git_url)'{-u,--url,--git_url}='[GIT URL to a repository containing the presentation]:url' \
'(-v --verbose)'{-v,--verbose}'[Show verbose messaging]' \
'(-x --execute --executecode)'{-x,--execute,--executecode}'[Enable remote code execution]' \
'1: :_files -/' && ret=0
;;
(skeleton|validate)
_arguments \
'(-f --file)'{-f,--file}'=[alternate json filename(default: none)]: :_files -g "*.json"' \
&& ret=0
;;
*)
(( ret )) && _message 'no more arguments'
;;
esac
;;
esac
case $state in
(args)
case $line[1] in
(add|new)
_arguments \
'(-d --dir)'{-d,--dir}='[Slide dir (where to put a new slide file)]:directory:_files -/' \
'(-n --name)'{-n,--name}='[Slide name (name of the new slide file)]:basename' \
{-s,--source}='[Include code from the given file as the slide body]:file:_files' \
'(-t --style --type)'{-t,--style,--type}='[Slide Type/Style (default: title)]:style' \
'(-u --nonumber)'{-u,--nonumber}"[Don't number the slide, use the given name verbatim]" \
'1:title' && ret=0
;;
(create|init)
_arguments \
'(-d --slidedir)'{-d,--slidedir}='[Sample slide directory name (default: one)]:arg' \
'(-n --nosamples)'{-n,--nosamples}="[Don't create sample slides]" \
'1:dir_name' && ret=0
;;
(help)
_arguments \
'-c[List commands one per line, to assist with shell completion]' \
'1: :_showoff_help' && ret=0
;;
(heroku)
_arguments \
'(-f --force)'{-f,--force}'[force overwrite of existing Gemfile, .gems and config.ru files if they exist]' \
'(-p --password)'{-p,--password}='[add password protection to your heroku site(default: none)]' \
'1:heroku_name' && ret=0
;;
(info)
_arguments \
'(-f --file)'{-f,--file}='[alternate json filename]: :_files -g "*.json"' \
'(-j --json)'{-j,--json}'[render output as json]' \
&& ret=0
;;
(pdf|static)
_arguments \
'(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \
'(-l --lang --language --locale)'{-l,--lang,--language,--locale}'[Language code to generate(default: none)]' \
'1:name' \
&& ret=0
;;
(serve)
_arguments \
'(-S --standalone)'{-S,--standalone}'[Run in standalone mode with no audience interaction]' \
'(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \
'--git_branch=[Branch of git repository to use(default: none)]:branch' \
'--git_path=[Path of the presentation within the git repository(default: none)]:path' \
'(-h --host)'{-h,--host}='[Host or IP to run on(default: 0.0.0.0)]' \
'--nocache[Disable content caching]'\
'--nosleep[Prevent the computer from sleeping during your presentation]' \
'(-p --port)'{-p,--port}='[Port on which to run(default: 9090)]' \
'(-r --review)'{-r,--review}'[Enable code review]'\
'(-s --ssl)'{-s,--ssl}'[Run via HTTPS]' \
'--ssl_certificate=[Path to SSL certificate]: :_files' \
'--ssl_private_key=[Path to SSL private key]: :_files' \
'(-u --url --git_url)'{-u,--url,--git_url}='[GIT URL to a repository containing the presentation]:url' \
'(-v --verbose)'{-v,--verbose}'[Show verbose messaging]' \
'(-x --execute --executecode)'{-x,--execute,--executecode}'[Enable remote code execution]' \
'1: :_files -/' && ret=0
;;
(skeleton|validate)
_arguments \
'(-f --file)'{-f,--file}'=[alternate json filename(default: none)]: :_files -g "*.json"' \
&& ret=0
;;
*)
(( ret )) && _message 'no more arguments'
;;
esac
;;
esac
return ret
}

186
src/_ufw
View File

@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for The Uncomplicated Firewall (ufw). (https://launchpad.net/ufw).
# Completion script for The Uncomplicated Firewall (ufw) v0.36.2. (https://launchpad.net/ufw).
#
# ------------------------------------------------------------------------------
# Authors
@ -38,108 +38,132 @@
#
# ------------------------------------------------------------------------------
_ufw_logging() {
local params additional second
second=$words[2]
local params additional second
second=$words[2]
if [ ! -z $second ]; then
return
fi
if [ ! -z $second ]; then
return
fi
params=("on" "off")
additional=("low" "medium" "high" "full")
params=(
"on"
"off"
)
additional=(
"low"
"medium"
"high"
"full"
)
_describe -t params 'on/off' params
_describe -t additional 'level' additional
_describe -t params 'on/off' params
_describe -t additional 'level' additional
}
_ufw_delete() {
local rules complrules second
local rules complrules second
second=$words[2]
second=$words[2]
if [ ! -z $second ]; then
return
fi
if [ ! -z $second ]; then
return
fi
complrules=()
rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}")
complrules=()
rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}")
for ((i=1; i<=${#rules[@]}; i++)); do
complrules+=("$i:$rules[i]");
done
for ((i=1; i<=${#rules[@]}; i++)); do
complrules+=("$i:$rules[i]");
done
_describe -t complrules 'Rules' complrules
_describe -t complrules 'Rules' complrules
}
_ufw_app() {
local ret=1
local -a subcmds=(
"list:list application profiles"
"info:show information on profile"
"update:update profile"
"default:set default application profile"
)
_arguments \
"1: :{_describe 'command' subcmds}" \
&& ret=0
return ret
}
(( $+functions[_flutter_pub_token_subcommand] )) ||
_flutter_pub_token_subcommand() {
local -a subcommands=(
)
_describe -t subcommands 'subcommand' subcommands "$@"
}
_ufw() {
local curcontext="$curcontext" ret=1
local -a state line commands
local curcontext="$curcontext" ret=1
local -a state line commands
commands=(
"enable:enable the firewall"
"disable:disable the firewall"
"default:set default policy"
"logging:set logging level"
"allow:add allow rule"
"deny:add deny rule"
"reject:add reject rule"
"limit:add limit rule"
"delete:delete rule"
"insert:insert rule at position"
"route:add route rule"
"reload:reload firewall"
"reset:reset firewall"
"status:show firewall status"
"show:show firewall report"
"version:display version information"
"prepend:add rule before all of the same type"
)
commands=(
"enable:enable the firewall"
"disable:disable the firewall"
"default:set default policy"
"logging:set logging level"
"allow:add allow rule"
"deny:add deny rule"
"reject:add reject rule"
"limit:add limit rule"
"delete:delete rule"
"insert:insert rule at position"
"route:add route rule"
"reload:reload firewall"
"reset:reset firewall"
"status:show firewall status"
"show:show firewall report"
"version:display version information"
"prepend:add rule before all of the same type"
"app:application profile command"
)
_arguments -C -s -S -n \
'(- 1 *)'--version"[display version information]: :->full" \
'(- 1 *)'{-h,--help}'[display usage information]: :->full' \
'(- 1 *)'--dry-run"[don't modify anything, just show the changes]: :->cmds" \
'1:cmd:->cmds' \
'*:: :->args' && ret=0
_arguments -C -s -S -n \
'(- 1 *)'--version"[display version information]: :->full" \
'(- 1 *)'{-h,--help}'[display usage information]: :->full' \
'(- 1 *)'--dry-run"[don't modify anything, just show the changes]: :->cmds" \
'1:cmd:->cmds' \
'*:: :->args' && ret=0
case "$state" in
(cmds)
_describe -t commands 'commands' commands
case "$state" in
(cmds)
_describe -t commands 'commands' commands
;;
(args)
local cmd
cmd=$words[1]
case "$cmd" in
(logging)
_ufw_logging && ret=0
;;
(delete)
_ufw_delete && ret=0
;;
(*)
_default && ret=0
;;
esac
(args)
local cmd
cmd=$words[1]
case "$cmd" in
(logging)
_ufw_logging && ret=0
;;
(delete)
_ufw_delete && ret=0
;;
(app)
_ufw_app && ret=0
;;
(*)
_default && ret=0
;;
esac
;;
(*)
(*)
;;
esac
esac
return ret
return ret
}
_ufw
_ufw "$@"
# 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

View File

@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for xsel (https://www.vergenet.net/~conrad/software/xsel/).
# Completion script for xsel v1.2.1 (https://www.vergenet.net/~conrad/software/xsel/).
#
# ------------------------------------------------------------------------------
# Authors
@ -45,6 +45,7 @@ local selection='(-p --primary -s --secondary -b --clipboard)'
_arguments -s \
$input{-a,--append}'[append standard input to the selection]' \
$input{-f,--follow}'[append to selection as standard input grows]' \
$input{-z,--zeroflush}'[overwrites selection when zero(\\0) is received]' \
$input{-i,--input}'[read standard input into the selection]' \
{-o,--output}'[write the selection to standard output]' \
$operation{-c,--clear}'[clear the selection]' \
@ -55,6 +56,7 @@ _arguments -s \
$operation{-k,--keep}'[do not modify the selections, but make the PRIMARY and SECONDARY selections persist even after the programs they were selected in exit]' \
$operation{-x,--exchange}'[exchange the PRIMARY and SECONDARY selections]' \
'--display[specify the server to use; see X(1)]:X display:_x_display' \
'--windowName[specify the X WM_ NAME window property]:window_name' \
{-t,--selectionTimeout}'[specify the timeout in milliseconds within which the selection must be retrieved]:number' \
{-l,--logfile}'[specify the file to log errors to when detached (default $HOME/.xsel.log)]:log file:_files' \
{-n,--nodetach}'[do not detach from the controlling terminal]' \

View File

@ -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
该函数的返回结果将被存入$replyreply即“回复”、“回应”数组里所以我们需要在$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
向补全数组$wordsarraywordsarray即“词数组”加入词汇
#+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