commit 1ce2420b917ca04c166f1aad47c8e73a0a353a9a Author: Price Hiller Date: Sat Jul 30 19:04:00 2022 -0500 initial commit diff --git a/.config/zsh/config/completions/completions/_Note b/.config/zsh/config/completions/completions/_Note new file mode 100644 index 0000000..5a8b776 --- /dev/null +++ b/.config/zsh/config/completions/completions/_Note @@ -0,0 +1,26 @@ +#compdef note + +local file_name_comp='*: :_files -W ${NOTES_DIR} -g "*.norg(:r)" -S " "' + +(( $+functions[_Note_subcommand] )) || +_Note_command() { + local -a args + args=( + {--open,-o}'[Create or edit a note]' + {--delete,-d}'[Delete a note]' + {--list,-l}'[List all notes]' + {--help,-h}'[Show help menu]' + {--version,-V}'[Show program version]' + "${file_name_comp}" + ) + + _arguments -S -s $args +} + +if (( ${#words} == 2 )); then + _Note_command +elif (( ${#words} == 3)); then + _arguments "${file_name_comp}" +elif (( ${#words} > 3 )) && [[ ${words[2]} = "--delete" || ${words[2]} = "-d" ]]; then + _arguments "${file_name_comp}" +fi diff --git a/.config/zsh/config/completions/completions/_aws b/.config/zsh/config/completions/completions/_aws new file mode 100644 index 0000000..2ff6bb5 --- /dev/null +++ b/.config/zsh/config/completions/completions/_aws @@ -0,0 +1,6 @@ +#compdef aws +_aws () { + local e + e=$(dirname ${funcsourcetrace[1]%:*})/aws_zsh_completer.sh + if [[ -f $e ]]; then source $e; fi +} diff --git a/.config/zsh/config/completions/completions/_bat b/.config/zsh/config/completions/completions/_bat new file mode 100644 index 0000000..6699067 --- /dev/null +++ b/.config/zsh/config/completions/completions/_bat @@ -0,0 +1,99 @@ +#compdef bat + +local context state state_descr line +typeset -A opt_args + +(( $+functions[_bat_cache_subcommand] )) || +_bat_cache_subcommand() { + local -a args + args=( + '(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]' + '(-b --build -c --clear)'{-c,--clear}'[Remove the cached syntax definitions and themes]' + '(--source)'--source='[Use a different directory to load syntaxes and themes from]:directory:_files -/' + '(--target)'--target='[Use a different directory to store the cached syntax and theme set]:directory:_files -/' + '(--blank)'--blank'[Create completely new syntax and theme sets]' + '(: -)'{-h,--help}'[Prints help information]' + '*: :' + ) + + _arguments -S -s $args +} + +(( $+functions[_bat_main] )) || +_bat_main() { + local -a args + args=( + '(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]' + '*'{-p,--plain}'[Show plain style (alias for `--style=plain`), repeat twice to disable disable automatic paging (alias for `--paging=never`)]' + '(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]::->language' + '(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:...' + '(--file-name)'--file-name'[Specify the name to display for a file]:...:_files' + '(-d --diff)'--diff'[Only show lines that have been added/removed/modified]' + '(--diff-context)'--diff-context'[Include N lines of context around added/removed/modified lines when using `--diff`]: (lines):()' + '(--tabs)'--tabs'[Set the tab width to T spaces]: (tab width):()' + '(--wrap)'--wrap='[Specify the text-wrapping mode]::(auto never character)' + '(--terminal-width)'--terminal-width'[Explicitly set the width of the terminal instead of determining it automatically]:' + '(-n --number)'{-n,--number}'[Show line numbers]' + '(--color)'--color='[When to use colors]::(auto never always)' + '(--italic-text)'--italic-text='[Use italics in output]::(always never)' + '(--decorations)'--decorations='[When to show the decorations]::(auto never always)' + '(--paging)'--paging='[Specify when to use the pager]::(auto never always)' + '(-m --map-syntax)'{-m+,--map-syntax=}'[Use the specified syntax for files matching the glob pattern]:...' + '(--theme)'--theme='[Set the color theme for syntax highlighting]::->theme' + '(: --list-themes --list-languages -L)'--list-themes'[Display all supported highlighting themes]' + '(--style)'--style='[Comma-separated list of style elements to display]::->style' + '(-r --line-range)'{-r+,--line-range=}'[Only print the lines from N to M]:...' + '(: --list-themes --list-languages -L)'{-L,--list-languages}'[Display all supported languages]' + '(: --no-config)'--no-config'[Do not use the configuration file]' + '(: --no-custom-assets)'--no-custom-assets'[Do not load custom assets]' + '(: --config-dir)'--config-dir'[Show bat'"'"'s configuration directory]' + '(: --config-file)'--config-file'[Show path to the configuration file]' + '(: --generate-config-file)'--generate-config-file'[Generates a default configuration file]' + '(: --cache-dir)'--cache-dir'[Show bat'"'"'s cache directory]' + '(: -)'{-h,--help}'[Print this help message]' + '(: -)'{-V,--version}'[Show version information]' + '*: :_files' + ) + + _arguments -S -s $args + + case "$state" in + language) + local IFS=$'\n' + local -a languages + languages=( $(bat --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') ) + + _describe 'language' languages + ;; + + theme) + local IFS=$'\n' + local -a themes + themes=( $(bat --list-themes | sort) ) + + _values 'theme' $themes + ;; + + style) + _values -s , 'style' auto full plain changes header grid rule numbers snip + ;; + esac +} + +# first positional argument +if (( ${#words} == 2 )); then + local -a subcommands + subcommands=('cache:Modify the syntax-definition and theme cache') + _describe subcommand subcommands + _bat_main +else + case $words[2] in + cache) + _bat_cache_subcommand + ;; + + *) + _bat_main + ;; + esac +fi diff --git a/.config/zsh/config/completions/completions/_cargo b/.config/zsh/config/completions/completions/_cargo new file mode 100644 index 0000000..5356313 --- /dev/null +++ b/.config/zsh/config/completions/completions/_cargo @@ -0,0 +1,426 @@ +#compdef cargo + +autoload -U regexp-replace + +_cargo() { + local curcontext="$curcontext" ret=1 + local -a command_scope_spec common parallel features msgfmt triple target registry + local -a state line state_descr # These are set by _arguments + typeset -A opt_args + + common=( + '(-q --quiet)*'{-v,--verbose}'[use verbose output]' + '(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]' + '-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags' + '--frozen[require that Cargo.lock and cache are up-to-date]' + '--locked[require that Cargo.lock is up-to-date]' + '--color=[specify colorization option]:coloring:(auto always never)' + '(- 1 *)'{-h,--help}'[show help message]' + ) + + # leading items in parentheses are an exclusion list for the arguments following that arg + # See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions + # - => exclude all other options + # 1 => exclude positional arg 1 + # * => exclude all other args + # +blah => exclude +blah + _arguments -s -S -C $common \ + '(- 1 *)--list[list installed commands]' \ + '(- 1 *)--explain=[provide a detailed explanation of an error message]:error code' \ + '(- 1 *)'{-V,--version}'[show version information]' \ + '(+beta +nightly)+stable[use the stable toolchain]' \ + '(+stable +nightly)+beta[use the beta toolchain]' \ + '(+stable +beta)+nightly[use the nightly toolchain]' \ + '1: :_cargo_cmds' \ + '*:: :->args' + + # These flags are mutually exclusive specifiers for the scope of a command; as + # they are used in multiple places without change, they are expanded into the + # appropriate command's `_arguments` where appropriate. + command_scope_spec=( + '(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names' + '(--bench --bin --test --lib)--example=[specify example name]:example name:_cargo_example_names' + '(--bench --example --test --lib)--bin=[specify binary name]:binary name' + '(--bench --bin --example --test)--lib=[specify library name]:library name' + '(--bench --bin --example --lib)--test=[specify test name]:test name' + ) + + parallel=( + '(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]' + ) + + features=( + '(--all-features)--features=[specify features to activate]:feature' + '(--features)--all-features[activate all available features]' + "--no-default-features[don't build the default features]" + ) + + msgfmt='--message-format=[specify error format]:error format [human]:(human json short)' + triple='--target=[specify target triple]:target triple:_cargo_target_triple' + target='--target-dir=[specify directory for all generated artifacts]:directory:_directories' + manifest='--manifest-path=[specify path to manifest]:path:_directories' + registry='--registry=[specify registry to use]:registry' + + case $state in + args) + curcontext="${curcontext%:*}-${words[1]}:" + case ${words[1]} in + bench) + _arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \ + "${command_scope_spec[@]}" \ + '--all-targets[benchmark all targets]' \ + "--no-run[compile but don't run]" \ + '(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \ + '--exclude=[exclude packages from the benchmark]:spec' \ + '--no-fail-fast[run all benchmarks regardless of failure]' \ + '1: :_guard "^-*" "bench name"' \ + '*:args:_default' + ;; + + build | b) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \ + "${command_scope_spec[@]}" \ + '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \ + '--release[build in release mode]' \ + '--build-plan[output the build plan in JSON]' \ + ;; + + check | c) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \ + "${command_scope_spec[@]}" \ + '(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \ + '--release[check in release mode]' \ + ;; + + clean) + _arguments -s -S $common $triple $target $manifest \ + '(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \ + '--release[clean release artifacts]' \ + '--doc[clean just the documentation directory]' + ;; + + doc | d) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--no-deps[do not build docs for dependencies]' \ + '--document-private-items[include non-public items in the documentation]' \ + '--open[open docs in browser after the build]' \ + '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \ + '--release[build artifacts in release mode, with optimizations]' \ + ;; + + fetch) + _arguments -s -S $common $triple $manifest + ;; + + fix) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + "${command_scope_spec[@]}" \ + '--broken-code[fix code even if it already has compiler errors]' \ + '--edition[fix in preparation for the next edition]' \ + '--edition-idioms[fix warnings to migrate to the idioms of an edition]' \ + '--allow-no-vcs[fix code even if a VCS was not detected]' \ + '--allow-dirty[fix code even if the working directory is dirty]' \ + '--allow-staged[fix code even if the working directory has staged changes]' + ;; + + generate-lockfile) + _arguments -s -S $common $manifest + ;; + + help) + _cargo_cmds + ;; + + init) + _arguments -s -S $common $registry \ + '--lib[use library template]' \ + '--edition=[specify edition to set for the crate generated]:edition:(2015 2018 2021)' \ + '--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \ + '--name=[set the resulting package name]:name' \ + '1:path:_directories' + ;; + + install) + _arguments -s -S $common $parallel $features $triple $registry \ + '(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \ + '--bin=[only install the specified binary]:binary' \ + '--branch=[branch to use when installing from git]:branch' \ + '--debug[build in debug mode instead of release mode]' \ + '--example=[install the specified example instead of binaries]:example:_cargo_example_names' \ + '--git=[specify URL from which to install the crate]:url:_urls' \ + '--path=[local filesystem path to crate to install]: :_directories' \ + '--rev=[specific commit to use when installing from git]:commit' \ + '--root=[directory to install packages into]: :_directories' \ + '--tag=[tag to use when installing from git]:tag' \ + '--vers=[version to install from crates.io]:version' \ + '--list[list all installed packages and their versions]' \ + '*: :_guard "^-*" "crate"' + ;; + + locate-project) + _arguments -s -S $common $manifest \ + '--message-format=[specify output representation]:output representation [json]:(json plain)' + '--workspace[locate Cargo.toml of the workspace root]' + ;; + + login) + _arguments -s -S $common $registry \ + '*: :_guard "^-*" "token"' + ;; + + metadata) + _arguments -s -S $common $features $manifest \ + "--no-deps[output information only about the root package and don't fetch dependencies]" \ + '--format-version=[specify format version]:version [1]:(1)' + ;; + + new) + _arguments -s -S $common $registry \ + '--lib[use library template]' \ + '--vcs:initialize a new repo with a given VCS:(git hg none)' \ + '--name=[set the resulting package name]' + ;; + + owner) + _arguments -s -S $common $registry \ + '(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \ + '--index=[specify registry index]:index' \ + '(-l --list)'{-l,--list}'[list owners of a crate]' \ + '(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \ + '--token=[specify API token to use when authenticating]:token' \ + '*: :_guard "^-*" "crate"' + ;; + + package) + _arguments -s -S $common $parallel $features $triple $target $manifest \ + '(-l --list)'{-l,--list}'[print files included in a package without making one]' \ + '--no-metadata[ignore warnings about a lack of human-usable metadata]' \ + '--allow-dirty[allow dirty working directories to be packaged]' \ + "--no-verify[don't build to verify contents]" + ;; + + pkgid) + _arguments -s -S $common $manifest \ + '(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \ + '*: :_guard "^-*" "spec"' + ;; + + publish) + _arguments -s -S $common $parallel $features $triple $target $manifest $registry \ + '--index=[specify registry index]:index' \ + '--allow-dirty[allow dirty working directories to be packaged]' \ + "--no-verify[don't verify the contents by building them]" \ + '--token=[specify token to use when uploading]:token' \ + '--dry-run[perform all checks without uploading]' + ;; + + read-manifest) + _arguments -s -S $common $manifest + ;; + + run | r) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--example=[name of the bin target]:name:_cargo_example_names' \ + '--bin=[name of the bin target]:name' \ + '(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \ + '--release[build in release mode]' \ + '*: :_default' + ;; + + rustc) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \ + '--profile=[specify profile to build the selected target for]:profile' \ + '--release[build artifacts in release mode, with optimizations]' \ + "${command_scope_spec[@]}" \ + '*: : _dispatch rustc rustc -default-' + ;; + + rustdoc) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--document-private-items[include non-public items in the documentation]' \ + '--open[open the docs in a browser after the operation]' \ + '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \ + '--release[build artifacts in release mode, with optimizations]' \ + "${command_scope_spec[@]}" \ + '*: : _dispatch rustdoc rustdoc -default-' + ;; + + search) + _arguments -s -S $common $registry \ + '--index=[specify registry index]:index' \ + '--limit=[limit the number of results]:results [10]' \ + '*: :_guard "^-*" "query"' + ;; + + test | t) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--test=[test name]: :_cargo_test_names' \ + '--no-fail-fast[run all tests regardless of failure]' \ + '--no-run[compile but do not run]' \ + '(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \ + '--all[test all packages in the workspace]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '1: :_cargo_test_names' \ + '(--doc --bin --example --test --bench)--lib[only test library]' \ + '(--lib --bin --example --test --bench)--doc[only test documentation]' \ + '(--lib --doc --example --test --bench)--bin=[binary name]' \ + '(--lib --doc --bin --test --bench)--example=[example name]:_cargo_example_names' \ + '(--lib --doc --bin --example --bench)--test=[test name]' \ + '(--lib --doc --bin --example --test)--bench=[benchmark name]' \ + '*: :_default' + ;; + + tree) + _arguments -s -S $common $features $triple $manifest \ + '(-p --package)'{-p+,--package=}'[package to use as the root]:package:_cargo_package_names' \ + '(-i --invert)'{-i+,--invert=}'[invert the tree for the given package]:package:_cargo_package_names' \ + '--prefix=[line prefix]:prefix:(depth indent none)' \ + '--no-dedupe[repeat shared dependencies]' \ + '(-d --duplicates)'{-d,--duplicates}'[packages with multiple versions]' \ + '--charset=[utf8 or ascii]:charset:(utf8 ascii)' \ + '(-f --format)'{-f,--format=}'[format string]:format' \ + '(-e --edges)'{-e,--edges=}'[edge kinds]:kind:(features normal build dev all no-dev no-build no-normal)' \ + ;; + + uninstall) + _arguments -s -S $common \ + '(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \ + '--bin=[only uninstall the specified binary]:name' \ + '--root=[directory to uninstall packages from]: :_files -/' \ + '*:crate:_cargo_installed_crates -F line' + ;; + + update) + _arguments -s -S $common $manifest \ + '--aggressive=[force dependency update]' \ + "--dry-run[don't actually write the lockfile]" \ + '(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \ + '--precise=[update single dependency to precise release]:release' + ;; + + verify-project) + _arguments -s -S $common $manifest + ;; + + version) + _arguments -s -S $common + ;; + + yank) + _arguments -s -S $common $registry \ + '--vers=[specify yank version]:version' \ + '--undo[undo a yank, putting a version back into the index]' \ + '--index=[specify registry index to yank from]:registry index' \ + '--token=[specify API token to use when authenticating]:token' \ + '*: :_guard "^-*" "crate"' + ;; + *) + # allow plugins to define their own functions + if ! _call_function ret _cargo-${words[1]}; then + # fallback on default completion for unknown commands + _default && ret=0 + fi + (( ! ret )) + ;; + esac + ;; + esac +} + +_cargo_unstable_flags() { + local flags + flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } ) + _describe -t flags 'unstable flag' flags +} + +_cargo_installed_crates() { + local expl + _description crates expl 'crate' + compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *} +} + +_cargo_cmds() { + local -a commands + # This uses Parameter Expansion Flags, which are a built-in Zsh feature. + # See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags + # and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion + # + # # How this work? + # + # First it splits the result of `cargo --list` at newline, then it removes the first line. + # Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]). + # Then it replaces those spaces between item and description with a `:` + # + # [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns + commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} ) + _describe -t commands 'command' commands +} + +_cargo_target_triple() { + local -a targets + targets=( ${(f)"$(rustc --print target-list)"} ) + _describe 'target triple' targets +} + +#FIXME: Disabled until fixed +#gets package names from the manifest file +_cargo_package_names() { + _message -e packages package +} + +# Extracts the values of "name" from the array given in $1 and shows them as +# command line options for completion +_cargo_names_from_array() { + local manifest=$(cargo locate-project --message-format plain) + if [[ -z $manifest ]]; then + return 0 + fi + + local last_line + local -a names; + local in_block=false + local block_name=$1 + names=() + while read -r line; do + if [[ $last_line == "[[$block_name]]" ]]; then + in_block=true + else + if [[ $last_line =~ '\s*\[\[.*' ]]; then + in_block=false + fi + fi + + if [[ $in_block == true ]]; then + if [[ $line =~ '\s*name\s*=' ]]; then + regexp-replace line '^\s*name\s*=\s*|"' '' + names+=( "$line" ) + fi + fi + + last_line=$line + done < "$manifest" + _describe "$block_name" names + +} + +#Gets the test names from the manifest file +_cargo_test_names() { + _cargo_names_from_array "test" +} + +#Gets the bench names from the manifest file +_cargo_benchmark_names() { + _cargo_names_from_array "bench" +} + +_cargo_example_names() { + if [[ -d examples ]]; then + local -a files=(${(@f)$(echo examples/*.rs(:t:r))}) + _values 'example' "${files[@]}" + fi +} + +_cargo diff --git a/.config/zsh/config/completions/completions/_cmake b/.config/zsh/config/completions/completions/_cmake new file mode 100644 index 0000000..a0b0a0e --- /dev/null +++ b/.config/zsh/config/completions/completions/_cmake @@ -0,0 +1,597 @@ +#compdef cmake -value-,CMAKE_GENERATOR,-default- +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://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 CMake (http://www.cmake.org). +# +# ------------------------------------------------------------------------- +# Authors +# ------- +# +# * Scott M. Kroll (initial version) +# * Paul Seyfert (handling of --build and updates) +# * Norbert Lange (presets, command mode, updates) +# +# ------------------------------------------------------------------------- +# Notes +# ----- +# +# * By default only C and C++ languages are supported for compiler flag +# variables. To define your own list of languages: +# +# cmake_langs=('C' 'C' +# 'CXX' 'C++') +# zstyle ':completion:*:cmake:*' languages $cmake_langs +# +# ------------------------------------------------------------------------- + +local context state line curcontext="$curcontext" cmake_args + +local cmake_build_options;cmake_build_options=( + '-S[Explicitly specify a source directory]:source directory:_path_files -/' + '-B[Explicitly specify a build directory]:build directory:_path_files -/' + '-C[Pre-load a script to populate the cache]:initial cache:_files' + '*-D-[Create a cmake cache entry]:property:_cmake_define_property' + '*-U[Remove matching entries from CMake cache]:globbing expression' + '-G[Specify a makefile generator]:generator:_cmake_generators' + '-T[Specify toolset name if supported by generator]:toolset name' + '-A[Specify platform name if supported by generator]:platform name' + + # Warnings + '(-Wdev)-Wno-dev[Suppress/Enable developer warnings]' + '(-Wno-dev)-Wdev[Suppress/Enable developer warnings]' + '(-Wdeprecated)-Wno-deprecated[Suppress/Enable deprecation warnings]' + '(-Wno-deprecated)-Wdeprecated[Suppress/Enable deprecation warnings]' + '(-Werror=dev)-Wno-error=dev[Make developer warnings (not) errors]' + '(-Wno-error=dev)-Werror=dev[Make developer warnings (not) errors]' + '(-Wno-error=deprecated)-Werror=deprecated[Make deprecated macro and function warnings (not) errors]' + '(-Werror=deprecated)-Wno-error=deprecated[Make deprecated macro and function warnings (not) errors]' + + '--preset=[Specify a configure preset]:preset:_cmake_presets' + '--list-presets[List available presets]' + + '-E[CMake command mode]:command:_cmake_command_help' + + '-L-[List cache variables]::_values "options" "[non-advanced cache variables]" "A[advanced cache variables]" "H[non-advanced cached variables with help]" "AH[advanced cache variables with help]"' + + '--build[Build a CMake-generated project binary tree]:project directory:_path_files -/' + '--install[Install a CMake-generated project binary tree]:project directory:_path_files -/' + '--open[Open generated project in the associated application]:project directory:_path_files -/' + + '-N[View mode only]' + '-P[Process script mode]:script:_files' + + '--find-package[Legacy pkg-config like mode. Do not use]' + + '--graphviz=[Generate graphviz of dependencies, see CMakeGraphVizOptions.cmake for more]:graphviz output:_files' + '--system-information[Dump information about this system]::system information output:_files' + + '--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]' + + '--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]' + + '(--trace-expand)--trace[Put cmake in trace mode]' + '(--trace)--trace-expand[Put cmake in trace mode with variable expansion]' + '--trace-format=[Set the output format of the trace]:trace format:(human json-v1)' + '*--trace-source[Trace only this CMake file/module. Multiple options allowed]:filename:_files' + '--trace-redirect[Redirect trace output to a file instead of stderr]:trace output:_files' + + '--warn-uninitialized[Warn about uninitialized values]' + '--no-warn-unused-cli[Do not warn about command line options]' + '--warn-unused-vars[Warn about unused variables]' + '--check-system-vars[Find problems with variable usage in system files]' + + '--profiling-format[Output data for profiling CMake scripts]:profiling format:(google-trace)' + '--profiling-output[Select an output path for the profiling data]:filename:_files' + + ':cmake project:_path_files -/' +) + +# ------------------------ +# _cmake_generator_options +# +# arguments are $1: build working directory (top level Makefile or build.ninja file) +# $2: position of "--" in the command line +# ------------------------ +(( $+functions[_cmake_generator_options] )) || +_cmake_generator_options() { + # pass only the part of the command line starting at "--" to the completion + shift (( $2 - 1 )) words + (( CURRENT = $CURRENT + 1 - $2 )) + if [ -f $1/Makefile ] + then + $_comps[make] + elif [ -f $1/build.ninja ] + then + $_comps[ninja] + fi +} + +# -------------- +# _cmake_presets +# -------------- +(( $+functions[_cmake_presets] )) || +_cmake_presets() { + local invoke; invoke=(${words[@]}) + # TODO: remove all arguments -* except -S + invoke[$CURRENT]=--list-presets + + # TODO: Problems with quotes need eval + # would need a way to exec the array + local list_presets; list_presets=(${(f)"$(eval "${invoke[@]} 2> /dev/null" | sed -n 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*-[[:space:]]*\(.*\),\1:\2,p' )"}) + + _describe 'presets' list_presets +} + +# -------------- +# _cmake_targets +# -------------- +(( $+functions[_cmake_targets] )) || +_cmake_targets() { + local -a targets + if [ -f $1/Makefile ] + then + # `make help` doesn't work for Makefiles in general, but for CMake generated Makefiles it does. + i=1 + for target in $(make -f $1/Makefile help | \grep -e "\.\.\." | sed "s/\.\.\. //" | sed "s/ (the default.*//") ; do + targets[$i]=$target + (( i = $i + 1 )) + done + elif [ -f $1/build.ninja ] + then + # `ninja help` doesn't seem to be the list of targets we're interested in + i=1 + for target in $(ninja -C $1 -t targets all 2&>/dev/null | awk -F: '{print $1}') ; do + targets[$i]="$target" + (( i++ )) + done + fi + _describe 'build targets' targets +} + +_cmake_suggest_builddirs() { + _alternative ':current directory:(.)' 'directory::_directories' && return 0 +} + +_cmake_suggest_installdirs() { + _alternative ':current directory:(.)' 'directory::_directories' && return 0 +} + +_cmake_on_build() { + local build_extras;build_extras=( + '--[Native build tool options]' + '--target[specify build target]' + '--clean-first[build target clean first]' + '--config[For multi-configuration tools]' + '--parallel[maximum number of build processes]' + '--use-stderr') + local -a undescribed_build_extras + i=1 + for be in $build_extras ; do + undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//") + (( i++ )) + done + inbuild=false + dashdashposition=-1 + for ((i = (($CURRENT - 1)); i > 1 ; i--)); do + if [[ $words[$i] == --build ]] ; then + inbuild=true + buildat=$i + (( difference = $CURRENT - $i )) + elif [[ $words[$i] == -- ]] ; then + dashdashposition=$i + fi + done + # check if build mode has been left + outofbuild=false + for ((i = (($CURRENT - 1)); i > (($buildat + 1)); i--)); do + # don't check the word after --build (should be a directory) + if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --target ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --config ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --parallel ]] ; then continue ; fi + outofbuild=true + done + if (( $dashdashposition > 0 )) ; then + _cmake_generator_options $words[(($buildat + 1))] $dashdashposition && return 0 + fi + if [[ "$inbuild" == false || "$difference" -eq 1 ]] ; then + # either there is no --build or completing the directory after --build + _arguments -C -s \ + - build_opts \ + "$cmake_build_options[@]" \ + - build_cmds \ + "$cmake_suggest_build[@]" && return 0 + elif [[ $words[(($CURRENT - 1))] == --target ]] ; then + # after --build --target, suggest targets + _cmake_targets $words[(($buildat + 1))] && return 0 + elif [[ $words[(($CURRENT - 1))] == --config ]] ; then + # after --build --config, no idea + return 0 + elif [[ $words[(($CURRENT - 1))] == --parallel ]] ; then + # after --build --parallel + return 0 + elif [ "$outofbuild" = true ] ; then + # after --build --, suggest other cmake_build_options (like -Wno-dev) + _arguments "$cmake_build_options[@]" && return 0 + else + # after --build , suggest other cmake_build_options (like -Wno-dev) or --build options (like --clean-first) + _arguments "$build_extras[@]" "$cmake_build_options[@]" && return 0 + fi +} + +_cmake_on_install() { + local build_extras;build_extras=( + '--[Native build tool options]' + '--prefix[Override the installation prefix, CMAKE_INSTALL_PREFIX]' + '--config[For multi-configuration generators(e.g. Visual Studio)]' + '--component[Component-based install]' + '--strip[Strip before installing.]' + ) + local -a undescribed_build_extras + i=1 + for be in $build_extras ; do + undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//") + (( i++ )) + done + inbuild=false + dashdashposition=-1 + for ((i = (($CURRENT - 1)); i > 1 ; i--)); do + if [[ $words[$i] == --install ]] ; then + inbuild=true + buildat=$i + (( difference = $CURRENT - $i )) + elif [[ $words[$i] == -- ]] ; then + dashdashposition=$i + fi + done + outofbuild=false + for ((i = (($CURRENT - 1)); i > (($buildat + 1)); i--)); do + # don't check the word after --install (should be a directory) + if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --prefix ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --config ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --component ]] ; then continue ; fi + outofbuild=true + done + if (( $dashdashposition > 0 )) ; then + _cmake_generator_options $words[(($buildat + 1))] $dashdashposition && return 0 + fi + if [[ "$inbuild" == false || "$difference" -eq 1 ]] ; then + # either there is no --install or completing the directory after --install + _arguments -C -s \ + - build_opts \ + "$cmake_build_options[@]" \ + - build_cmds \ + "$cmake_suggest_install[@]" && return 0 + elif [[ $words[(($CURRENT - 1))] == --prefix ]] ; then + # after --install --prefix, no idea + return 0 + elif [[ $words[(($CURRENT - 1))] == --config ]] ; then + # after --install --config, no idea + return 0 + elif [[ $words[(($CURRENT - 1))] == --component ]] ; then + # after --build --component, no idea + return 0 + elif [ "$outofbuild" = true ] ; then + # after --build --, suggest other cmake_build_options (like -Wno-dev) + _arguments "$cmake_build_options[@]" && return 0 + else + # after --build , suggest other cmake_build_options (like -Wno-dev) or --build options (like --clean-first) + _arguments "$build_extras[@]" "$cmake_build_options[@]" && return 0 + fi +} + +local cmake_help_actions;cmake_help_actions=( + '(- 1)'{--help,-help,-usage,-h,-H}'[Print usage information and exit]' + '(- 1)'{--version,-version}'[Print version number and exit]' + '(- 1)--help-full[Print all help manuals and exit]' + '(- 1)--help-manual[Print one help manual and exit]:module-name: _cmake_list_names --help-manual-list "manual name"' + '(- 1)--help-manual-list[List help manuals available and exit]' + '(- 1)--help-command[Print help for one command and exit]:command-name: _cmake_list_names --help-command-list "command name"' + '(- 1)--help-command-list[List commands with help available and exit]' + '(- 1)--help-commands[Print cmake-commands manual and exit]' + '(- 1)--help-module[Print help for one module and exit]:module-name: _cmake_list_names --help-module-list "module name"' + '(- 1)--help-module-list[List modules with help available and exit]' + '(- 1)--help-modules[Print cmake-modules manual and exit]' + '(- 1)--help-policy[Print help for one policy and exit]:policy-name: _cmake_list_names --help-policy-list "policy name"' + '(- 1)--help-policy-list[List policies with help available and exit]' + '(- 1)--help-policies[Print cmake-policies manual and exit]' + '(- 1)--help-property[Print help for one property and exit]:property-name: _cmake_list_names --help-property-list "property name" brakremove' + '(- 1)--help-property-list[List properties with help available and exit]' + '(- 1)--help-properties[Print cmake-properties manual and exit]' + '(- 1)--help-variable[Print help for one variable and exit]:variable-name: _cmake_list_names --help-variable-list "variable name" brakremove' + '(- 1)--help-variable-list[List variables with help available and exit]' + '(- 1)--help-variables[Print cmake-variables manual and exit]' +) +_cmake_help() { + _arguments -C -s - help "$cmake_help_actions[@]" +} + +# ----------------- +# _cmake_list_names +# ----------------- +(( $+functions[_cmake_list_names] )) || +_cmake_list_names() { + local command; command="$@[1]" + local desc; desc="$@[2]" + local opts; opts=($@[3]) + local list_names; list_names=(${(f)"$($service $command 2> /dev/null)"}) + # Older CMake (< 3.0) writes out the version + list_names=(${^list_names##cmake version*}) + + if [[ ${opts[(i)brakremove]} -le ${#opts} ]]; then + list_names=(${^list_names//\[/\\\[}) + list_names=(${^list_names//\]/\\\]}) + fi + + _values ${desc} ${list_names[@]:-1} && return 0 +} + +# ---------------------- +# _cmake_define_property +# ---------------------- +(( $+functions[_cmake_define_property] )) || +_cmake_define_property() { + if compset -P '*='; then + _wanted property-values expl 'property value' _cmake_define_property_values ${${IPREFIX%=}#-D} && return 0 + else + _wanted property-names expl 'property name' _cmake_define_property_names -qS= && return 0 + fi +} + +# ---------------------------- +# _cmake_define_property_names +# ---------------------------- +(( $+functions[_cmake_define_property_names] )) || +_cmake_define_property_names() { + local alternatives; alternatives=( + 'common-property-names:common property name:_cmake_define_common_property_names -qS=' + ) + local -A cmake_langs + zstyle -a ":completion:${curcontext}:" languages cmake_langs + [[ $#cmake_langs -eq 0 ]] && cmake_langs=('C' 'C' 'CXX' 'C++') + + for cmake_lang in ${(k)cmake_langs}; do + cmake_lang_desc="${cmake_langs[$cmake_lang]}" + alternatives+=("${cmake_lang//:/-}-property-names:${cmake_lang_desc} language property name:_cmake_define_lang_property_names -qS= ${cmake_lang} ${cmake_lang_desc}") + done + + _alternative "${alternatives[@]}" +} + +# --------------------------------- +# _cmake_define_lang_property_names +# --------------------------------- +(( $+functions[_cmake_define_lang_property_names] )) || +_cmake_define_lang_property_names() { + local cmake_lang="$@[-2]" cmake_lang_desc="$@[-1]" + local properties; properties=( + "CMAKE_${cmake_lang}_COMPILER:${cmake_lang_desc} compiler" + "CMAKE_${cmake_lang}_COMPILER_LAUNCHER:${cmake_lang_desc} compiler launcher (e.g. ccache)" + "CMAKE_${cmake_lang}_FLAGS:${cmake_lang_desc} compiler flags for all builds" + "CMAKE_${cmake_lang}_FLAGS_DEBUG:${cmake_lang_desc} compiler flags for all Debug build" + "CMAKE_${cmake_lang}_FLAGS_RELEASE:${cmake_lang_desc} compiler flags for all Release build" + "CMAKE_${cmake_lang}_FLAGS_MINSIZREL:${cmake_lang_desc} compiler flags for all MinSizRel build" + "CMAKE_${cmake_lang}_FLAGS_RELWITHDEBINFO:${cmake_lang_desc} compiler flags for all RelWithDebInfo build" + "CMAKE_${cmake_lang}_STANDARD:${cmake_lang_desc} language standard" + "CMAKE_${cmake_lang}_STANDARD_REQUIRED:${cmake_lang_desc} language standard is required" + "CMAKE_${cmake_lang}_EXTENSIONS:${cmake_lang_desc} enable compiler specific extensions" + ) + + _describe -t "${cmake_lang//:/-}-property-names" "${cmake_lang_desc} property name" properties $@[0,-3] && return 0 +} + +# ----------------------------------- +# _cmake_define_common_property_names +# ----------------------------------- +(( $+functions[_cmake_define_common_property_names] )) || +_cmake_define_common_property_names() { + local properties; properties=( + 'CMAKE_MODULE_PATH:Search path for CMake modules (FindPROJECT.cmake)' + 'CMAKE_PREFIX_PATH:Search path for installations (PROJECTConfig.cmake)' + 'CMAKE_BUILD_TYPE:Specifies the build type for make based generators' + 'CMAKE_TOOLCHAIN_FILE:Absolute or relative path to a CMake script which sets up toolchain related variables' + 'CMAKE_COLOR_MAKEFILE:Enables/disables color output when using the Makefile generator' + 'CMAKE_INSTALL_PREFIX:Install directory used by install' + 'CMAKE_EXPORT_COMPILE_COMMANDS:Enable/disable output of compilation database during generation' + 'CMAKE_RULE_MESSAGES:Specify whether to report a message for each make rule' + 'CMAKE_VERBOSE_MAKEFILE:Enable verbose output from Makefile builds' + 'CMAKE_UNITY_BUILD:Batch include source files' + ) + + _describe -t 'common-property-names' 'common property name' properties $@ +} + +local _cmake_build_types=('Debug' 'Release' 'RelWithDebInfo' 'MinSizeRel') +local _cmake_c_standards=(90 99 11) +local _cmake_cxx_standards=(98 11 14 17 20) + +# ---------------------------- +# _cmake_define_property_values +# ---------------------------- +(( $+functions[_cmake_define_property_values] )) || +_cmake_define_property_values() { + local ret=1 + setopt localoptions extendedglob + case $@[-1] in + (CMAKE_BUILD_TYPE) _wanted build-types expl 'build type' _values 'build type' ${_cmake_build_types[@]} && ret=0;; + (CMAKE_CXX_STANDARD) _wanted cxx-standards expl 'cxx standard' _values 'cxx standard' ${_cmake_cxx_standards[@]} && ret=0;; + (CMAKE_C_STANDARD) _wanted c-standards expl 'c standard' _values 'c standard' ${_cmake_c_standards[@]} && ret=0;; + (CMAKE_TOOLCHAIN_FILE) _wanted toolchain-files expl 'file' _cmake_toolchain_files && ret=0;; + (CMAKE_COLOR_MAKEFILE) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_RULE_MESSAGES) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_VERBOSE_MAKEFILE) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_UNITY_BUILD) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_INSTALL_PREFIX) _files -/ && ret=0;; + (CMAKE_EXPORT_COMPILE_COMMANDS) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_*_COMPILER) _wanted compilers expl 'compiler' _cmake_compilers && ret=0;; + (CMAKE_*_COMPILER_LAUNCHER) _wanted compilers expl 'compiler launcher' _cmake_launchers && ret=0;; + (CMAKE_*_FLAGS(|_?*)) _message -e compiler-flags 'compiler flags' && _dispatch $service -value-,CPPFLAGS,-default- && ret=0;; + (CMAKE_*_STANDARD_REQUIRED) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_*_EXTENSIONS) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (*) _files && ret=0;; + esac + + return ret +} + +local _cmake_generator_list +_cmake_generator_list=( + 'Green Hills MULTI' + 'Unix Makefiles' + 'Ninja' + 'Ninja Multi-Config' + 'CodeBlocks - Ninja' + 'CodeBlocks - Unix Makefiles' + 'CodeLite - Ninja' + 'CodeLite - Unix Makefiles' + 'Eclipse CDT4 - Ninja' + 'Eclipse CDT4 - Unix Makefiles' + 'Kate - Ninja' + 'Kate - Unix Makefiless' + 'Sublime Text 2 - Ninja' + 'Sublime Text 2 - Unix Makefiles' +) + +# ----------------- +# _cmake_generators +# ----------------- +(( $+functions[_cmake_generators] )) || +_cmake_generators() { + _describe -t generators 'generator' _cmake_generator_list +} + +# ---------------------- +# _cmake_toolchain_files +# ---------------------- +(( $+functions[_cmake_toolchain_files] )) || +_cmake_toolchain_files() { + _files -g '*\.cmake*' +} + + +local _cmake_booleans=(_describe -t booleans 'boolean' 'YES' 'NO') + +# --------------- +# _cmake_compilers +# +# by default just executable commands, but can be overridden by users. +# --------------- +(( $+functions[_cmake_compilers] )) || +_cmake_compilers() { + _command_names -e +} + +# --------------- +# _cmake_launchers +# +# by default just executable commands, but can be overridden by users. +# useful commands might be ccache, distcc, ... +# --------------- +(( $+functions[_cmake_launchers] )) || +_cmake_launchers() { + _command_names -e +} + +local _cmake_commands=( + 'capabilities:Report capabilities built into cmake in JSON format' \ + 'cat:concat the files and print them to the standard output' \ + 'chdir:run command in a given directory' \ + 'compare_files:check if file1 is same as file2' \ + 'copy:copy files to destination (either file or directory)' \ + 'copy_directory:copy content of ... directories to destination directory' \ + 'copy_if_different:copy files if it has changed' \ + 'echo:displays arguments as text' \ + 'echo_append:displays arguments as text but no new line' \ + 'env:run command in a modified environment' \ + 'environment:display the current environment' \ + 'make_directory:create parent and directories' \ + 'md5sum:create MD5 checksum of files' \ + 'sha1sum:create SHA1 checksum of files' \ + 'sha224sum:create SHA224 checksum of files' \ + 'sha256sum:create SHA256 checksum of files' \ + 'sha384sum:create SHA384 checksum of files' \ + 'sha512sum:create SHA512 checksum of files' \ + 'remove:remove the file(s), use -f to force it' \ + 'remove_directory:remove directories and their contents' \ + 'rename:rename a file or directory (on one volume)' \ + 'rm:remove files or directories' \ + 'server:start cmake in server mode' \ + 'sleep:sleep for given number of seconds' \ + 'tar:create or extract a tar or zip archive' \ + 'time:run command and display elapsed time' \ + 'touch:touch a ' \ + 'touch_nocreate:touch a but do not create it' \ + 'create_symlink:create a symbolic link new -> old' \ + 'create_hardlink:create a hard link new -> old' \ + 'true:do nothing with an exit code of 0' \ + 'false:do nothing with an exit code of 1' +) +_cmake_command() { + _arguments -C \ + '-E[CMake command mode]:command:(("${_cmake_commands[@]}"))' + +} +local cmake_suggest_build;cmake_suggest_build=( + '--build[build]:build dir:_cmake_suggest_builddirs' +) + +local cmake_suggest_install;cmake_suggest_install=( + '--install[install]:install dir:_cmake_suggest_installdirs' +) + +if [[ "$service" = -value-*CMAKE_GENERATOR* ]]; then + _cmake_generators +elif [ $CURRENT -eq 2 ] ; then + _arguments -C -s \ + - help \ + "$cmake_help_actions[@]" \ + - command \ + '-E[CMake command mode]:command:( )' \ + - build_opts \ + "$cmake_build_options[@]" \ + - build_cmds \ + "$cmake_suggest_build[@]" \ + - install_cmds \ + "$cmake_suggest_install[@]" && return 0 +elif [[ $words[2] = --help* ]] ; then + _cmake_help +elif [[ $words[2] == --build ]] ; then + _cmake_on_build +elif [[ $words[2] == --install ]] ; then + _cmake_on_install +elif [[ $words[2] == -E ]]; then + _cmake_command +else + _arguments "$cmake_build_options[@]" +fi diff --git a/.config/zsh/config/completions/completions/_curl b/.config/zsh/config/completions/completions/_curl new file mode 100644 index 0000000..f42ea95 --- /dev/null +++ b/.config/zsh/config/completions/completions/_curl @@ -0,0 +1,257 @@ +#compdef curl + +# curl zsh completion + +local curcontext="$curcontext" state state_descr line +typeset -A opt_args + +local rc=1 + +_arguments -C -S \ + --aws-sigv4'[Use AWS V4 signature authentication]':'' \ + {-c,--cookie-jar}'[Write cookies to after operation]':'':_files \ + --resolve'[Resolve the host+port to this address]':'<[+]host\:port\:addr[,addr]...>' \ + {-D,--dump-header}'[Write the received headers to ]':'':_files \ + {-y,--speed-time}'[Trigger '\''speed-limit'\'' abort after this time]':'' \ + --proxy-cacert'[CA certificate to verify peer against for proxy]':'':_files \ + --happy-eyeballs-timeout-ms'[Time for IPv6 before trying IPv4]':'' \ + --proxy-ssl-auto-client-cert'[Use auto client certificate for proxy (Schannel)]' \ + {-E,--cert}'[Client certificate file and password]':'' \ + --connect-timeout'[Maximum time allowed for connection]':'' \ + --etag-save'[Parse ETag from a request and save it to a file]':'':_files \ + --libcurl'[Dump libcurl equivalent code of this command line]':'':_files \ + --proxy-capath'[CA directory to verify peer against for proxy]':'':_files \ + --proxy-pinnedpubkey'[FILE/HASHES public key to verify proxy with]':'' \ + --doh-cert-status'[Verify the status of the DoH server cert via OCSP-staple]' \ + --etag-compare'[Pass an ETag from a file as a custom header]':'':_files \ + --curves'[(EC) TLS key exchange algorithm(s) to request]':'' \ + --proxy-negotiate'[Use HTTP Negotiate (SPNEGO) authentication on the proxy]' \ + --hostpubsha256'[Acceptable SHA256 hash of the host public key]':'' \ + --mail-rcpt-allowfails'[Allow RCPT TO command to fail for some recipients]' \ + {-m,--max-time}'[Maximum time allowed for transfer]':'' \ + --socks5-hostname'[SOCKS5 proxy, pass host name to proxy]':'' \ + --abstract-unix-socket'[Connect via abstract Unix domain socket]':'' \ + --pinnedpubkey'[FILE/HASHES Public key to verify peer against]':'' \ + --proxy-insecure'[Do HTTPS proxy connections without verifying the proxy]' \ + --proxy-pass'[Pass phrase for the private key for HTTPS proxy]':'' \ + --proxy-ssl-allow-beast'[Allow security flaw for interop for HTTPS proxy]' \ + {-p,--proxytunnel}'[Operate through an HTTP proxy tunnel (using CONNECT)]' \ + --proto-default'[Use PROTOCOL for any URL missing a scheme]':'' \ + --proxy-tls13-ciphers'[TLS 1.3 proxy cipher suites]':'' \ + --socks5-gssapi-service'[SOCKS5 proxy service name for GSS-API]':'' \ + --ftp-alternative-to-user'[String to replace USER \[name\]]':'' \ + {-T,--upload-file}'[Transfer local FILE to destination]':'':_files \ + --form-escape'[Escape multipart form field/file names using backslash]' \ + --local-port'[Force use of RANGE for local port numbers]':'' \ + --proxy-tlsauthtype'[TLS authentication type for HTTPS proxy]':'' \ + {-R,--remote-time}'[Set the remote file'\''s time on the local output]' \ + --ssl-revoke-best-effort'[Ignore missing/offline cert CRL dist points]' \ + --ftp-ssl-control'[Require SSL/TLS for FTP login, clear for transfer]' \ + --parallel-immediate'[Do not wait for multiplexing (with --parallel)]' \ + --cert-status'[Verify the status of the server cert via OCSP-staple]' \ + --proxy-cert-type'[Client certificate type for HTTPS proxy]':'' \ + {-Q,--quote}'[Send command(s) to server before transfer]':'' \ + {-O,--remote-name}'[Write output to a file named as the remote file]' \ + --retry-connrefused'[Retry on connection refused (use with --retry)]' \ + --sasl-authzid'[Identity for SASL PLAIN authentication]':'' \ + --suppress-connect-headers'[Suppress proxy CONNECT response headers]' \ + --trace-ascii'[Like --trace, but without hex output]':'':_files \ + --expect100-timeout'[How long to wait for 100-continue]':'' \ + {-g,--globoff}'[Disable URL sequences and ranges using {} and \[\]]' \ + {-j,--junk-session-cookies}'[Ignore session cookies read from file]' \ + --parallel-max'[Maximum concurrency for parallel transfers]':'' \ + --tls13-ciphers'[TLS 1.3 cipher suites to use]':'' \ + --dns-ipv4-addr'[IPv4 address to use for DNS requests]':'
' \ + --dns-ipv6-addr'[IPv6 address to use for DNS requests]':'
' \ + --location-trusted'[Like --location, and send auth to other hosts]' \ + --mail-auth'[Originator address of the original email]':'
' \ + --noproxy'[List of hosts which do not use proxy]':'' \ + --proto-redir'[Enable/disable PROTOCOLS on redirect]':'' \ + --proxy-cert'[Set client certificate for proxy]':'' \ + --dns-interface'[Interface to use for DNS requests]':'' \ + --hostpubmd5'[Acceptable MD5 hash of the host public key]':'' \ + --keepalive-time'[Interval time for keepalive probes]':'' \ + --random-file'[File for reading random data from]':'':_files \ + --socks5-basic'[Enable username/password auth for SOCKS5 proxies]' \ + --cacert'[CA certificate to verify peer against]':'':_files \ + {-H,--header}'[Pass custom header(s) to server]':'
' \ + --ignore-content-length'[Ignore the size of the remote resource]' \ + {-i,--include}'[Include protocol response headers in the output]' \ + --preproxy'[\[protocol\://\]host\[\:port\] Use this proxy first]' \ + --proxy-header'[Pass custom header(s) to proxy]':'
' \ + --unix-socket'[Connect through this Unix domain socket]':'' \ + {-w,--write-out}'[Use output FORMAT after completion]':'' \ + {-b,--cookie}'[Send cookies from string/file]':'' \ + {-o,--output}'[Write to file instead of stdout]':'':_files \ + --request-target'[Specify the target for this request]':'' \ + --socks4a'[SOCKS4a proxy on given host + port]':'' \ + --ssl-auto-client-cert'[Use auto client certificate (Schannel)]' \ + {-U,--proxy-user}'[Proxy user and password]':'' \ + --proxy1.0'[Use HTTP/1.0 proxy on given port]':'' \ + {-Y,--speed-limit}'[Stop transfers slower than this]':'' \ + {-z,--time-cond}'[Transfer based on a time condition]':'