initial commit
This commit is contained in:
commit
1ce2420b91
26
.config/zsh/config/completions/completions/_Note
Normal file
26
.config/zsh/config/completions/completions/_Note
Normal file
@ -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
|
6
.config/zsh/config/completions/completions/_aws
Normal file
6
.config/zsh/config/completions/completions/_aws
Normal file
@ -0,0 +1,6 @@
|
||||
#compdef aws
|
||||
_aws () {
|
||||
local e
|
||||
e=$(dirname ${funcsourcetrace[1]%:*})/aws_zsh_completer.sh
|
||||
if [[ -f $e ]]; then source $e; fi
|
||||
}
|
99
.config/zsh/config/completions/completions/_bat
Normal file
99
.config/zsh/config/completions/completions/_bat
Normal file
@ -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>:->language'
|
||||
'(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:<N\:M>...'
|
||||
'(--file-name)'--file-name'[Specify the name to display for a file]:<name>...:_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`]:<N> (lines):()'
|
||||
'(--tabs)'--tabs'[Set the tab width to T spaces]:<T> (tab width):()'
|
||||
'(--wrap)'--wrap='[Specify the text-wrapping mode]:<when>:(auto never character)'
|
||||
'(--terminal-width)'--terminal-width'[Explicitly set the width of the terminal instead of determining it automatically]:<width>'
|
||||
'(-n --number)'{-n,--number}'[Show line numbers]'
|
||||
'(--color)'--color='[When to use colors]:<when>:(auto never always)'
|
||||
'(--italic-text)'--italic-text='[Use italics in output]:<when>:(always never)'
|
||||
'(--decorations)'--decorations='[When to show the decorations]:<when>:(auto never always)'
|
||||
'(--paging)'--paging='[Specify when to use the pager]:<when>:(auto never always)'
|
||||
'(-m --map-syntax)'{-m+,--map-syntax=}'[Use the specified syntax for files matching the glob pattern]:<glob\:syntax>...'
|
||||
'(--theme)'--theme='[Set the color theme for syntax highlighting]:<theme>:->theme'
|
||||
'(: --list-themes --list-languages -L)'--list-themes'[Display all supported highlighting themes]'
|
||||
'(--style)'--style='[Comma-separated list of style elements to display]:<components>:->style'
|
||||
'(-r --line-range)'{-r+,--line-range=}'[Only print the lines from N to M]:<N\: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
|
426
.config/zsh/config/completions/completions/_cargo
Normal file
426
.config/zsh/config/completions/completions/_cargo
Normal file
@ -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
|
597
.config/zsh/config/completions/completions/_cmake
Normal file
597
.config/zsh/config/completions/completions/_cmake
Normal file
@ -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 <skroll@gmail.com> (initial version)
|
||||
# * Paul Seyfert <pseyfert.mathphys@gmail.com> (handling of --build and updates)
|
||||
# * Norbert Lange <nolange79@gmail.com> (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 <dir> --target, suggest targets
|
||||
_cmake_targets $words[(($buildat + 1))] && return 0
|
||||
elif [[ $words[(($CURRENT - 1))] == --config ]] ; then
|
||||
# after --build <dir> --config, no idea
|
||||
return 0
|
||||
elif [[ $words[(($CURRENT - 1))] == --parallel ]] ; then
|
||||
# after --build <dir> --parallel
|
||||
return 0
|
||||
elif [ "$outofbuild" = true ] ; then
|
||||
# after --build <dir> --<not a --build option>, suggest other cmake_build_options (like -Wno-dev)
|
||||
_arguments "$cmake_build_options[@]" && return 0
|
||||
else
|
||||
# after --build <dir>, 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 <dir> --prefix, no idea
|
||||
return 0
|
||||
elif [[ $words[(($CURRENT - 1))] == --config ]] ; then
|
||||
# after --install <dir> --config, no idea
|
||||
return 0
|
||||
elif [[ $words[(($CURRENT - 1))] == --component ]] ; then
|
||||
# after --build <dir> --component, no idea
|
||||
return 0
|
||||
elif [ "$outofbuild" = true ] ; then
|
||||
# after --build <dir> --<not a --build option>, suggest other cmake_build_options (like -Wno-dev)
|
||||
_arguments "$cmake_build_options[@]" && return 0
|
||||
else
|
||||
# after --build <dir>, 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 <dir>... 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 <dir> 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 <file>' \
|
||||
'touch_nocreate:touch a <file> 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
|
257
.config/zsh/config/completions/completions/_curl
Normal file
257
.config/zsh/config/completions/completions/_curl
Normal file
@ -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]':'<provider1[\:provider2[\:region[\:service]]]>' \
|
||||
{-c,--cookie-jar}'[Write cookies to <filename> after operation]':'<filename>':_files \
|
||||
--resolve'[Resolve the host+port to this address]':'<[+]host\:port\:addr[,addr]...>' \
|
||||
{-D,--dump-header}'[Write the received headers to <filename>]':'<filename>':_files \
|
||||
{-y,--speed-time}'[Trigger '\''speed-limit'\'' abort after this time]':'<seconds>' \
|
||||
--proxy-cacert'[CA certificate to verify peer against for proxy]':'<file>':_files \
|
||||
--happy-eyeballs-timeout-ms'[Time for IPv6 before trying IPv4]':'<milliseconds>' \
|
||||
--proxy-ssl-auto-client-cert'[Use auto client certificate for proxy (Schannel)]' \
|
||||
{-E,--cert}'[Client certificate file and password]':'<certificate[\:password]>' \
|
||||
--connect-timeout'[Maximum time allowed for connection]':'<fractional seconds>' \
|
||||
--etag-save'[Parse ETag from a request and save it to a file]':'<file>':_files \
|
||||
--libcurl'[Dump libcurl equivalent code of this command line]':'<file>':_files \
|
||||
--proxy-capath'[CA directory to verify peer against for proxy]':'<dir>':_files \
|
||||
--proxy-pinnedpubkey'[FILE/HASHES public key to verify proxy with]':'<hashes>' \
|
||||
--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]':'<file>':_files \
|
||||
--curves'[(EC) TLS key exchange algorithm(s) to request]':'<algorithm list>' \
|
||||
--proxy-negotiate'[Use HTTP Negotiate (SPNEGO) authentication on the proxy]' \
|
||||
--hostpubsha256'[Acceptable SHA256 hash of the host public key]':'<sha256>' \
|
||||
--mail-rcpt-allowfails'[Allow RCPT TO command to fail for some recipients]' \
|
||||
{-m,--max-time}'[Maximum time allowed for transfer]':'<fractional seconds>' \
|
||||
--socks5-hostname'[SOCKS5 proxy, pass host name to proxy]':'<host[\:port]>' \
|
||||
--abstract-unix-socket'[Connect via abstract Unix domain socket]':'<path>' \
|
||||
--pinnedpubkey'[FILE/HASHES Public key to verify peer against]':'<hashes>' \
|
||||
--proxy-insecure'[Do HTTPS proxy connections without verifying the proxy]' \
|
||||
--proxy-pass'[Pass phrase for the private key for HTTPS proxy]':'<phrase>' \
|
||||
--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]':'<protocol>' \
|
||||
--proxy-tls13-ciphers'[TLS 1.3 proxy cipher suites]':'<ciphersuite list>' \
|
||||
--socks5-gssapi-service'[SOCKS5 proxy service name for GSS-API]':'<name>' \
|
||||
--ftp-alternative-to-user'[String to replace USER \[name\]]':'<command>' \
|
||||
{-T,--upload-file}'[Transfer local FILE to destination]':'<file>':_files \
|
||||
--form-escape'[Escape multipart form field/file names using backslash]' \
|
||||
--local-port'[Force use of RANGE for local port numbers]':'<num/range>' \
|
||||
--proxy-tlsauthtype'[TLS authentication type for HTTPS proxy]':'<type>' \
|
||||
{-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]':'<type>' \
|
||||
{-Q,--quote}'[Send command(s) to server before transfer]':'<command>' \
|
||||
{-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]':'<identity>' \
|
||||
--suppress-connect-headers'[Suppress proxy CONNECT response headers]' \
|
||||
--trace-ascii'[Like --trace, but without hex output]':'<file>':_files \
|
||||
--expect100-timeout'[How long to wait for 100-continue]':'<seconds>' \
|
||||
{-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]':'<num>' \
|
||||
--tls13-ciphers'[TLS 1.3 cipher suites to use]':'<ciphersuite list>' \
|
||||
--dns-ipv4-addr'[IPv4 address to use for DNS requests]':'<address>' \
|
||||
--dns-ipv6-addr'[IPv6 address to use for DNS requests]':'<address>' \
|
||||
--location-trusted'[Like --location, and send auth to other hosts]' \
|
||||
--mail-auth'[Originator address of the original email]':'<address>' \
|
||||
--noproxy'[List of hosts which do not use proxy]':'<no-proxy-list>' \
|
||||
--proto-redir'[Enable/disable PROTOCOLS on redirect]':'<protocols>' \
|
||||
--proxy-cert'[Set client certificate for proxy]':'<cert[\:passwd]>' \
|
||||
--dns-interface'[Interface to use for DNS requests]':'<interface>' \
|
||||
--hostpubmd5'[Acceptable MD5 hash of the host public key]':'<md5>' \
|
||||
--keepalive-time'[Interval time for keepalive probes]':'<seconds>' \
|
||||
--random-file'[File for reading random data from]':'<file>':_files \
|
||||
--socks5-basic'[Enable username/password auth for SOCKS5 proxies]' \
|
||||
--cacert'[CA certificate to verify peer against]':'<file>':_files \
|
||||
{-H,--header}'[Pass custom header(s) to server]':'<header/@file>' \
|
||||
--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]':'<header/@file>' \
|
||||
--unix-socket'[Connect through this Unix domain socket]':'<path>' \
|
||||
{-w,--write-out}'[Use output FORMAT after completion]':'<format>' \
|
||||
{-b,--cookie}'[Send cookies from string/file]':'<data|filename>' \
|
||||
{-o,--output}'[Write to file instead of stdout]':'<file>':_files \
|
||||
--request-target'[Specify the target for this request]':'<path>' \
|
||||
--socks4a'[SOCKS4a proxy on given host + port]':'<host[\:port]>' \
|
||||
--ssl-auto-client-cert'[Use auto client certificate (Schannel)]' \
|
||||
{-U,--proxy-user}'[Proxy user and password]':'<user\:password>' \
|
||||
--proxy1.0'[Use HTTP/1.0 proxy on given port]':'<host[\:port]>' \
|
||||
{-Y,--speed-limit}'[Stop transfers slower than this]':'<speed>' \
|
||||
{-z,--time-cond}'[Transfer based on a time condition]':'<time>' \
|
||||
--alt-svc'[Enable alt-svc with this cache file]':'<file name>' \
|
||||
--capath'[CA directory to verify peer against]':'<dir>':_files \
|
||||
--connect-to'[Connect to host]':'<HOST1\:PORT1\:HOST2\:PORT2>' \
|
||||
{-f,--fail}'[Fail silently (no output at all) on HTTP errors]' \
|
||||
--http2-prior-knowledge'[Use HTTP 2 without HTTP/1.1 Upgrade]' \
|
||||
--proxy-tlspassword'[TLS password for HTTPS proxy]':'<string>' \
|
||||
{-r,--range}'[Retrieve only the bytes within RANGE]':'<range>' \
|
||||
--socks4'[SOCKS4 proxy on given host + port]':'<host[\:port]>' \
|
||||
--socks5'[SOCKS5 proxy on given host + port]':'<host[\:port]>' \
|
||||
{-A,--user-agent}'[Send User-Agent <name> to server]':'<name>' \
|
||||
--egd-file'[EGD socket path for random data]':'<file>':_files \
|
||||
--fail-early'[Fail on first transfer error, do not continue]' \
|
||||
{-x,--proxy}'[\[protocol\://\]host\[\:port\] Use this proxy]' \
|
||||
{-J,--remote-header-name}'[Use the header-provided filename]' \
|
||||
--retry-max-time'[Retry only within this period]':'<seconds>' \
|
||||
{-:,--next}'[Make next URL use its separate set of options]' \
|
||||
--proxy-key-type'[Private key file type for proxy]':'<type>' \
|
||||
--retry'[Retry request if transient problems occur]':'<num>' \
|
||||
--ssl-no-revoke'[Disable cert revocation checks (Schannel)]' \
|
||||
--create-dirs'[Create necessary local directory hierarchy]' \
|
||||
--haproxy-protocol'[Send HAProxy PROXY protocol v1 header]' \
|
||||
--max-redirs'[Maximum number of redirects allowed]':'<num>' \
|
||||
{-n,--netrc}'[Must read .netrc for user name and password]' \
|
||||
--proxy-crlfile'[Set a CRL list for proxy]':'<file>':_files \
|
||||
--sasl-ir'[Enable initial response in SASL authentication]' \
|
||||
--socks5-gssapi-nec'[Compatibility with NEC SOCKS5 server]' \
|
||||
--ssl-allow-beast'[Allow security flaw to improve interop]' \
|
||||
--create-file-mode'[File mode for created files]':'<mode>' \
|
||||
--ftp-create-dirs'[Create the remote dirs if not present]' \
|
||||
--interface'[Use network INTERFACE (or address)]':'<name>' \
|
||||
--key-type'[Private key file type (DER/PEM/ENG)]':'<type>' \
|
||||
--netrc-file'[Specify FILE for netrc]':'<filename>':_files \
|
||||
{-N,--no-buffer}'[Disable buffering of the output stream]' \
|
||||
--proxy-service-name'[SPNEGO proxy service name]':'<name>' \
|
||||
--remote-name-all'[Use the remote file name for all URLs]' \
|
||||
{-X,--request}'[Specify request method to use]':'<method>' \
|
||||
{-u,--user}'[Server user and password]':'<user\:password>' \
|
||||
--fail-with-body'[Fail on HTTP errors but save the body]' \
|
||||
--max-filesize'[Maximum file size to download]':'<bytes>' \
|
||||
--negotiate'[Use HTTP Negotiate (SPNEGO) authentication]' \
|
||||
--no-keepalive'[Disable TCP keepalive on the connection]' \
|
||||
--output-dir'[Directory to save files in]':'<dir>':_files \
|
||||
{-#,--progress-bar}'[Display transfer progress as a bar]' \
|
||||
--retry-all-errors'[Retry all errors (use with --retry)]' \
|
||||
--socks5-gssapi'[Enable GSS-API auth for SOCKS5 proxies]' \
|
||||
{-K,--config}'[Read config from a file]':'<file>':_files \
|
||||
{-C,--continue-at}'[Resumed transfer offset]':'<offset>' \
|
||||
--data-raw'[HTTP POST data, '\''@'\'' allowed]':'<data>' \
|
||||
--hsts'[Enable HSTS with this cache file]':'<file name>' \
|
||||
--krb'[Enable Kerberos with security <level>]':'<level>' \
|
||||
--proxy-ciphers'[SSL ciphers to use for proxy]':'<list>' \
|
||||
--proxy-digest'[Use Digest authentication on the proxy]' \
|
||||
--proxy-tlsuser'[TLS username for HTTPS proxy]':'<name>' \
|
||||
--styled-output'[Enable styled output for HTTP headers]' \
|
||||
--tls-max'[Set maximum allowed TLS version]':'<VERSION>' \
|
||||
--data-urlencode'[HTTP POST data url encoded]':'<data>' \
|
||||
--delegation'[GSS-API delegation permission]':'<LEVEL>' \
|
||||
--doh-insecure'[Allow insecure DoH server connections]' \
|
||||
{-P,--ftp-port}'[Use PORT instead of PASV]':'<address>' \
|
||||
--post301'[Do not switch to GET after following a 301]' \
|
||||
--post302'[Do not switch to GET after following a 302]' \
|
||||
--post303'[Do not switch to GET after following a 303]' \
|
||||
--proxy-anyauth'[Pick any proxy authentication method]' \
|
||||
--trace-time'[Add time stamps to trace/verbose output]' \
|
||||
--cert-type'[Certificate type (DER/PEM/ENG)]':'<type>' \
|
||||
--disallow-username-in-url'[Disallow username in url]' \
|
||||
--dns-servers'[DNS server addrs to use]':'<addresses>' \
|
||||
{-G,--get}'[Put the post data in the URL and use GET]' \
|
||||
--limit-rate'[Limit transfer speed to RATE]':'<speed>' \
|
||||
--ntlm-wb'[Use HTTP NTLM authentication with winbind]' \
|
||||
--path-as-is'[Do not squash .. sequences in URL path]' \
|
||||
--proxy-basic'[Use Basic authentication on the proxy]' \
|
||||
--retry-delay'[Wait time between retries]':'<seconds>' \
|
||||
--trace'[Write a debug trace to FILE]':'<file>':_files \
|
||||
{-a,--append}'[Append to target file when uploading]' \
|
||||
--ftp-ssl-ccc-mode'[Set CCC mode]':'<active/passive>' \
|
||||
--metalink'[Process given URLs as metalink XML file]' \
|
||||
--no-progress-meter'[Do not show the progress meter]' \
|
||||
--tr-encoding'[Request compressed transfer encoding]' \
|
||||
--xattr'[Store metadata in extended file attributes]' \
|
||||
{-k,--insecure}'[Allow insecure server connections]' \
|
||||
--pass'[Pass phrase for the private key]':'<phrase>' \
|
||||
--proxy-ntlm'[Use NTLM authentication on the proxy]' \
|
||||
{-S,--show-error}'[Show error even when -s is used]' \
|
||||
--stderr'[Where to redirect stderr]':'<file>':_files \
|
||||
--ciphers'[SSL ciphers to use]':'<list of ciphers>' \
|
||||
--form-string'[Specify multipart MIME data]':'<name=string>' \
|
||||
--login-options'[Server login options]':'<options>' \
|
||||
--tftp-blksize'[Set TFTP BLKSIZE option]':'<value>' \
|
||||
{-v,--verbose}'[Make the operation more talkative]' \
|
||||
--ftp-skip-pasv-ip'[Skip the IP address for PASV]' \
|
||||
--proxy-key'[Private key for HTTPS proxy]':'<key>' \
|
||||
{-F,--form}'[Specify multipart MIME data]':'<name=content>' \
|
||||
{-h,--help}'[Get help for commands]':'<category>' \
|
||||
--mail-from'[Mail from this address]':'<address>' \
|
||||
--oauth2-bearer'[OAuth 2 Bearer Token]':'<token>' \
|
||||
--proto'[Enable/disable PROTOCOLS]':'<protocols>' \
|
||||
--tftp-no-options'[Do not send any TFTP options]' \
|
||||
--tlsauthtype'[TLS authentication type]':'<type>' \
|
||||
--doh-url'[Resolve host names over DoH]':'<URL>' \
|
||||
--no-sessionid'[Disable SSL session-ID reusing]' \
|
||||
{-Z,--parallel}'[Perform transfers in parallel]' \
|
||||
--data-binary'[HTTP POST binary data]':'<data>' \
|
||||
--mail-rcpt'[Mail to this address]':'<address>' \
|
||||
{-t,--telnet-option}'[Set telnet option]':'<opt=val>' \
|
||||
--crlfile'[Use this CRL list]':'<file>':_files \
|
||||
--ftp-ssl-ccc'[Send CCC after authenticating]' \
|
||||
{-4,--ipv4}'[Resolve names to IPv4 addresses]' \
|
||||
{-6,--ipv6}'[Resolve names to IPv6 addresses]' \
|
||||
--service-name'[SPNEGO service name]':'<name>' \
|
||||
{-V,--version}'[Show version number and quit]' \
|
||||
--data-ascii'[HTTP POST ASCII data]':'<data>' \
|
||||
--ftp-account'[Account data string]':'<data>' \
|
||||
--disable-eprt'[Inhibit using EPRT or LPRT]' \
|
||||
--ftp-method'[Control CWD usage]':'<method>' \
|
||||
--netrc-optional'[Use either .netrc or URL]' \
|
||||
--pubkey'[SSH Public key file name]':'<key>' \
|
||||
--raw'[Do HTTP "raw"; no transfer decoding]' \
|
||||
--anyauth'[Pick any authentication method]' \
|
||||
--compressed'[Request compressed response]' \
|
||||
--ftp-pasv'[Use PASV/EPSV instead of PORT]' \
|
||||
--no-alpn'[Disable the ALPN TLS extension]' \
|
||||
--tcp-nodelay'[Use the TCP_NODELAY option]' \
|
||||
{-B,--use-ascii}'[Use ASCII/text transfer]' \
|
||||
--compressed-ssh'[Enable SSH compression]' \
|
||||
--digest'[Use HTTP Digest Authentication]' \
|
||||
--proxy-tlsv1'[Use TLSv1 for HTTPS proxy]' \
|
||||
--engine'[Crypto engine to use]':'<name>' \
|
||||
--no-npn'[Disable the NPN TLS extension]' \
|
||||
--basic'[Use HTTP Basic Authentication]' \
|
||||
{-M,--manual}'[Display the full manual]' \
|
||||
--tlspassword'[TLS password]':'<string>' \
|
||||
--false-start'[Enable TLS False Start]' \
|
||||
--crlf'[Convert LF to CRLF in upload]' \
|
||||
{-d,--data}'[HTTP POST data]':'<data>' \
|
||||
{-I,--head}'[Show document info only]' \
|
||||
--key'[Private key file name]':'<key>' \
|
||||
--ntlm'[Use HTTP NTLM authentication]' \
|
||||
{-e,--referer}'[Referrer URL]':'<URL>' \
|
||||
{-1,--tlsv1}'[Use TLSv1.0 or greater]' \
|
||||
--http0.9'[Allow HTTP 0.9 responses]' \
|
||||
--disable-epsv'[Inhibit using EPSV]' \
|
||||
--ftp-pret'[Send PRET before PASV]' \
|
||||
{-L,--location}'[Follow redirects]' \
|
||||
--tcp-fastopen'[Use TCP Fast Open]' \
|
||||
--tlsuser'[TLS user name]':'<name>' \
|
||||
--tlsv1.0'[Use TLSv1.0 or greater]' \
|
||||
--tlsv1.1'[Use TLSv1.1 or greater]' \
|
||||
--tlsv1.2'[Use TLSv1.2 or greater]' \
|
||||
--tlsv1.3'[Use TLSv1.3 or greater]' \
|
||||
{-l,--list-only}'[List only mode]' \
|
||||
{-q,--disable}'[Disable .curlrc]' \
|
||||
--url'[URL to work with]':'<url>' \
|
||||
{-0,--http1.0}'[Use HTTP 1.0]' \
|
||||
--ssl-reqd'[Require SSL/TLS]' \
|
||||
{-s,--silent}'[Silent mode]' \
|
||||
--http1.1'[Use HTTP 1.1]' \
|
||||
{-2,--sslv2}'[Use SSLv2]' \
|
||||
{-3,--sslv3}'[Use SSLv3]' \
|
||||
--http3'[Use HTTP v3]' \
|
||||
--http2'[Use HTTP 2]' \
|
||||
--ssl'[Try SSL/TLS]' \
|
||||
'*:URL:_urls' && rc=0
|
||||
|
||||
return rc
|
1
.config/zsh/config/completions/completions/_delta
Normal file
1
.config/zsh/config/completions/completions/_delta
Normal file
@ -0,0 +1 @@
|
||||
compdef _gnu_generic delta
|
8
.config/zsh/config/completions/completions/_dotnet
Normal file
8
.config/zsh/config/completions/completions/_dotnet
Normal file
@ -0,0 +1,8 @@
|
||||
#compdef dotnet
|
||||
_dotnet_zsh_complete()
|
||||
{
|
||||
local completions=("$(dotnet complete "$words")")
|
||||
|
||||
reply=( "${(ps:\n:)completions}" )
|
||||
}
|
||||
compctl -K _dotnet_zsh_complete dotnet
|
59
.config/zsh/config/completions/completions/_exa
Normal file
59
.config/zsh/config/completions/completions/_exa
Normal file
@ -0,0 +1,59 @@
|
||||
#compdef exa
|
||||
|
||||
# Save this file as _exa in /usr/local/share/zsh/site-functions or in any
|
||||
# other folder in $fpath. E. g. save it in a folder called ~/.zfunc and add a
|
||||
# line containing `fpath=(~/.zfunc $fpath)` somewhere before `compinit` in your
|
||||
# ~/.zshrc.
|
||||
|
||||
__exa() {
|
||||
# Give completions using the `_arguments` utility function with
|
||||
# `-s` for option stacking like `exa -ab` for `exa -a -b` and
|
||||
# `-S` for delimiting options with `--` like in `exa -- -a`.
|
||||
_arguments -s -S \
|
||||
"(- *)"{-v,--version}"[Show version of exa]" \
|
||||
"(- *)"{-'\?',--help}"[Show list of command-line options]" \
|
||||
{-1,--oneline}"[Display one entry per line]" \
|
||||
{-l,--long}"[Display extended file metadata as a table]" \
|
||||
{-G,--grid}"[Display entries as a grid]" \
|
||||
{-x,--across}"[Sort the grid across, rather than downwards]" \
|
||||
{-R,--recurse}"[Recurse into directories]" \
|
||||
{-T,--tree}"[Recurse into directories as a tree]" \
|
||||
{-F,--classify}"[Display type indicator by file names]" \
|
||||
--colo{,u}r"[When to use terminal colours]" \
|
||||
--colo{,u}r-scale"[Highlight levels of file sizes distinctly]" \
|
||||
--icons"[Display icons]" \
|
||||
--no-icons"[Hide icons]" \
|
||||
--group-directories-first"[Sort directories before other files]" \
|
||||
--git-ignore"[Ignore files mentioned in '.gitignore']" \
|
||||
{-a,--all}"[Show hidden and 'dot' files]" \
|
||||
{-d,--list-dirs}"[List directories like regular files]" \
|
||||
{-D,--only-dirs}"[List only directories]" \
|
||||
{-L,--level}"+[Limit the depth of recursion]" \
|
||||
{-r,--reverse}"[Reverse the sort order]" \
|
||||
{-s,--sort}="[Which field to sort by]:(sort field):(accessed age changed created date extension Extension filename Filename inode modified oldest name Name newest none size time type)" \
|
||||
{-I,--ignore-glob}"[Ignore files that match these glob patterns]" \
|
||||
{-b,--binary}"[List file sizes with binary prefixes]" \
|
||||
{-B,--bytes}"[List file sizes in bytes, without any prefixes]" \
|
||||
--changed"[Use the changed timestamp field]" \
|
||||
{-g,--group}"[List each file's group]" \
|
||||
{-h,--header}"[Add a header row to each column]" \
|
||||
{-H,--links}"[List each file's number of hard links]" \
|
||||
{-i,--inode}"[List each file's inode number]" \
|
||||
{-m,--modified}"[Use the modified timestamp field]" \
|
||||
{-n,--numeric}"[List numeric user and group IDs.]" \
|
||||
{-S,--blocks}"[List each file's number of filesystem blocks]" \
|
||||
{-t,--time}="[Which time field to show]:(time field):(accessed changed created modified)" \
|
||||
--time-style="[How to format timestamps]:(time style):(default iso long-iso full-iso)" \
|
||||
--no-permissions"[Suppress the permissions field]" \
|
||||
--octal-permissions"[List each file's permission in octal format]" \
|
||||
--no-filesize"[Suppress the filesize field]" \
|
||||
--no-user"[Suppress the user field]" \
|
||||
--no-time"[Suppress the time field]" \
|
||||
{-u,--accessed}"[Use the accessed timestamp field]" \
|
||||
{-U,--created}"[Use the created timestamp field]" \
|
||||
--git"[List each file's Git status, if tracked]" \
|
||||
{-@,--extended}"[List each file's extended attributes and sizes]" \
|
||||
'*:filename:_files'
|
||||
}
|
||||
|
||||
__exa
|
339
.config/zsh/config/completions/completions/_fail2ban-client
Normal file
339
.config/zsh/config/completions/completions/_fail2ban-client
Normal file
@ -0,0 +1,339 @@
|
||||
#compdef fail2ban-client
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2020 Github zsh-users - http://github.com/zsh-users
|
||||
# All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for fail2ban-client (https://www.fail2ban.org/).
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Felix Neumärker <xdch47@posteo.de>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_f2bc_jails() {
|
||||
LANG=C fail2ban-client status 2> /dev/null | sed -n -e 's/.*Jail list:\s\+//' -e 'T' -e 's/,\s\+/\'$'\n/g' -e 'p'
|
||||
}
|
||||
|
||||
_complete_f2bc_cmds() {
|
||||
local cmds=(
|
||||
'unban:unbans all IP addresses'
|
||||
'set:set property'
|
||||
'get:get property'
|
||||
'status:gets the current status of the server'
|
||||
'reload:reloads the configuration/jails'
|
||||
'restart:restarts the server'
|
||||
'start:starts the server and the jails'
|
||||
'stop:stops all jails and terminate the server'
|
||||
'ping:tests if the server is alive'
|
||||
'flushlogs:flushes the logtarget if a file and reopens it'
|
||||
'help:return this output'
|
||||
'version:return the server version'
|
||||
)
|
||||
|
||||
_describe -V "fail2ban commands" cmds
|
||||
}
|
||||
|
||||
_complete_f2bc_cmdargs() {
|
||||
local f2barg="$words[$NORMARG]"
|
||||
case "$f2barg" in
|
||||
unban)
|
||||
local jail
|
||||
if (( $words[(I)(--all)] == 0 )) ; then
|
||||
for jail in $(_f2bc_jails) ; do
|
||||
_complete_f2bc_ips $jail
|
||||
done
|
||||
local unban_opts=(--all)
|
||||
_describe -o "unban options" unban_opts
|
||||
else
|
||||
_nothing
|
||||
fi
|
||||
;;
|
||||
(set|get))
|
||||
if (( $NORMARG + 1 == $CURRENT )) ; then
|
||||
_complete_f2bc_jails
|
||||
_complete_f2bc_settings
|
||||
else
|
||||
_complete_f2bc_jail${f2barg}
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
if (( $NORMARG + 1 == $CURRENT )) ; then
|
||||
_complete_f2bc_jails
|
||||
elif (( $NORMARG + 2 == $CURRENT )) ; then
|
||||
_values "flavor" basic cymru
|
||||
else
|
||||
_nothing
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_complete_f2bc_jails() {
|
||||
local jails=($(_f2bc_jails))
|
||||
_describe -V "jails" jails
|
||||
}
|
||||
|
||||
_complete_f2bc_ips() {
|
||||
local ips=("${(@f)$(LANG=C fail2ban-client status $1 2> /dev/null | sed -n -e 's/^.*Banned IP list:\s\+//' -e 'T' -e 's/\s\+/\'$'\n/g' -e 'p')}")
|
||||
if [[ -n "${ips[@]}" ]] ; then
|
||||
_describe -t "f2b_jail_$1" -V "banned ips of jail $1" ips
|
||||
else
|
||||
_nothing
|
||||
fi
|
||||
}
|
||||
|
||||
_complete_f2bc_jailset() {
|
||||
if (( $NORMARG + 2 == $CURRENT )) ; then
|
||||
case $words[$NORMARG+1] in
|
||||
loglevel)
|
||||
local loglevel=(CRITICAL ERROR WARNING NOTICE INFO DEBUG TRACEDEBUG HEAVYDEBUG)
|
||||
_describe -V "loglevel" loglevel ;;
|
||||
logtarget)
|
||||
local logtarget=(STDOUT STDERR SYSLOG)
|
||||
_describe -V "logtarget" logtarget
|
||||
_files ;;
|
||||
syslogsocket)
|
||||
local syslogsocket=(auto)
|
||||
_describe -V "logtarget" syslogsocket
|
||||
_files ;;
|
||||
dbfile)
|
||||
_files ;;
|
||||
dbpurgeage)
|
||||
_message "sets the max age in <SECONDS> that history of bans will be kept" ;;
|
||||
*)
|
||||
# jail
|
||||
local jailsettings=(
|
||||
unbanip
|
||||
banip
|
||||
action
|
||||
addaction
|
||||
addfailregex
|
||||
addignoreip
|
||||
addignoreregex
|
||||
addjournalmatch
|
||||
addlogpath
|
||||
bantime
|
||||
datepattern
|
||||
delaction
|
||||
delfailregex
|
||||
delignoreip
|
||||
delignorerexgex
|
||||
deljournalmatch
|
||||
dellogpath
|
||||
findtime
|
||||
idle
|
||||
ignorecache
|
||||
ignorecommand
|
||||
ignoreself
|
||||
logencoding
|
||||
maxlines
|
||||
maxretry
|
||||
usedns
|
||||
)
|
||||
_describe -t "f2b_jail_setting" -V "jail setting" jailsettings ;;
|
||||
esac
|
||||
else
|
||||
local jail="$words[$NORMARG+1]"
|
||||
|
||||
if (( $NORMARG + 3 == $CURRENT )) ; then
|
||||
case $words[$NORMARG+2] in
|
||||
unbanip)
|
||||
_complete_f2bc_ips "$jail" ;;
|
||||
delfailregex)
|
||||
_complete_f2bc_regex fail "$jail" ;;
|
||||
delignorerexgex)
|
||||
_complete_f2bc_regex ignore "$jail" ;;
|
||||
dellogpath)
|
||||
local filelist=("${(@f)$(LANG=C fail2ban-client status $jail 2> /dev/null | sed -n -e 's/^.*File list:\s\+//' -e 'T' -e 's/\s\+/\'$'\n/g' -e 'p')}")
|
||||
|
||||
if [[ -n "${filelist[@]}" ]] ; then
|
||||
_describe -t "f2b_filelist" -V "filelist of jail $1" filelist
|
||||
else
|
||||
_nothing
|
||||
fi ;;
|
||||
idle)
|
||||
_values 'fail2ban idle' on off ;;
|
||||
ignoreself)
|
||||
_values 'fail2ban ignoreself' true false ;;
|
||||
delignoreip)
|
||||
local ignoreips=("${(@f)$(fail2ban-client get "$jail" ignoreip 2> /dev/null | sed -e 's/^[|`]-\s\+//p')}")
|
||||
if [[ -n "${ignoreips[@]}" ]] ; then
|
||||
_describe -t "f2b_ignoreip" -V "fail2ban ignored ips" ignoreips
|
||||
else
|
||||
_nothing
|
||||
fi ;;
|
||||
delaction|action)
|
||||
_complete_f2bc_action "$jail" ;;
|
||||
addlogpath)
|
||||
_files ;;
|
||||
*)
|
||||
_message "No completion for ${words[NORMARG+2]}" ;;
|
||||
esac
|
||||
elif (( $NORMARG + 4 == $CURRENT )) ; then
|
||||
case $words[$NORMARG+2] in
|
||||
action)
|
||||
_complete_f2bc_actionproperties "$jail" $words[$NORMARG+3] ;;
|
||||
addaction)
|
||||
_files ;;
|
||||
*)
|
||||
_nothing ;;
|
||||
esac
|
||||
else
|
||||
_nothing
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_complete_f2bc_jailget() {
|
||||
if (( $NORMARG + 2 == $CURRENT )) ; then
|
||||
case $words[$NORMARG+1] in
|
||||
(loglevel|logtarget|syslogsocket|dbfile|dbpurgeage))
|
||||
_nothing ;;
|
||||
*)
|
||||
# jail
|
||||
local jailprops=(
|
||||
logpath
|
||||
logencoding
|
||||
journalmatch
|
||||
ignoreself
|
||||
ignoreip
|
||||
ignorecommand
|
||||
failregex
|
||||
ignoreregex
|
||||
findtime
|
||||
bantime
|
||||
datepattern
|
||||
usedns
|
||||
maxretry
|
||||
maxlines
|
||||
actions
|
||||
action
|
||||
actionproperties
|
||||
actionmethods
|
||||
)
|
||||
_describe -t "f2b_jail_props" -V "jail properties" jailprops ;;
|
||||
esac
|
||||
else
|
||||
local jail="$words[$NORMARG+1]"
|
||||
|
||||
if (( $NORMARG + 3 == $CURRENT )) ; then
|
||||
case $words[$NORMARG+2] in
|
||||
(action|actionproperties|actionmethods))
|
||||
_complete_f2bc_action "$jail" ;;
|
||||
*)
|
||||
_nothing ;;
|
||||
esac
|
||||
elif (( $NORMARG + 4 == $CURRENT )) ; then
|
||||
case $words[$NORMARG+2] in
|
||||
(action|actionproperties|actionmethods))
|
||||
_complete_f2bc_actionproperties "$jail" $words[$NORMARG+3] ;;
|
||||
*)
|
||||
_nothing ;;
|
||||
esac
|
||||
else
|
||||
_nothing
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_complete_f2bc_action() {
|
||||
local jailactions=("${(@f)$(fail2ban-client get $1 actions 2>/dev/null | sed -e '1d' -e 's/,\s\+/\'$'\n/g')}")
|
||||
|
||||
if [[ -n "${jailactions[@]}" ]] ; then
|
||||
_describe -t "f2b_jail_actions" -V "jail actions" jailactions
|
||||
else
|
||||
_nothing
|
||||
fi
|
||||
}
|
||||
|
||||
_complete_f2bc_actionproperties() {
|
||||
local default_actionproperties=(
|
||||
actionstart
|
||||
actionstop
|
||||
actioncheck
|
||||
actionban
|
||||
actionunban
|
||||
timeout
|
||||
)
|
||||
local all_actionproperties=("${(@f)$(fail2ban-client get $1 actionproperties $2 2>/dev/null | sed -e '1d' -e 's/,\s\+/\'$'\n/g')}")
|
||||
local add_actionproperties=("${(@)all_actionproperties:|default_actionproperties}")
|
||||
|
||||
_describe -t "f2b_actions_defprops" -V "default action properties" default_actionproperties
|
||||
|
||||
if [[ -n "${add_actionproperties[@]}" ]] ; then
|
||||
_describe -t "f2b_actions_remprops" -V "additional action properties" add_actionproperties
|
||||
else
|
||||
_nothing
|
||||
fi
|
||||
}
|
||||
|
||||
_complete_f2bc_regex() {
|
||||
local regex=("${(@f)$(fail2ban-client get $2 ${1}regex 2> /dev/null | sed -n -e 's/[|`]- \[\([0-9]\+\)\]:\s\+/\1:/p')}")
|
||||
if [[ -n "${regex[@]}" ]] ; then
|
||||
_describe -t "f2b_regex" -V "jail $2 ${1}regex" regex
|
||||
else
|
||||
_nothing
|
||||
fi
|
||||
}
|
||||
|
||||
_complete_f2bc_settings() {
|
||||
local setargs=(loglevel logtarget syslogsocket dbfile dbpurgeage)
|
||||
_describe -t "f2b_settings" -V "fail2ban-client settings" setargs
|
||||
}
|
||||
|
||||
integer NORMARG
|
||||
|
||||
_arguments -A "-*" -n \
|
||||
'-c[configuration directory]:_files -/' \
|
||||
'-s[socket path]:_files' \
|
||||
'-p[pidfile path]:_files' \
|
||||
'--loglevel[logging level]:(CRITICAL ERROR WARNING, NOTICE INFO, DEBUG, TRACEDEBUG HEAVYDEBUG)' \
|
||||
'--logtarget[logging target]:(stdout stderr syslog sysout)' \
|
||||
'--syslogsocket:_files' \
|
||||
'-d[dump configuration]' \
|
||||
'(--dp --dump-pretty)'{--dp,--dump-pretty}'[dump the configuration using more human readable representation]' \
|
||||
'(-t --test)'{-t,--test}'[test configuration]' \
|
||||
'-i[interactive mode]' \
|
||||
'-v[increase verbosity]' \
|
||||
'-q[decrease verbosity]' \
|
||||
'-x[force execution of the server (remove socket file)]' \
|
||||
'-b[start server in background]' \
|
||||
'-f[start server in foreground]' \
|
||||
'--str2sec[convert time abbreviation format to seconds]:_message str2sec' \
|
||||
'(-h --help)'{-h,--help}'[display this help message]' \
|
||||
'(-V --version)'{-V,--version}'[print the version]' \
|
||||
'1:fail2ban command:_complete_f2bc_cmds' \
|
||||
'*:fail2ban command argument:_complete_f2bc_cmdargs'
|
||||
|
||||
# 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:
|
273
.config/zsh/config/completions/completions/_fd
Normal file
273
.config/zsh/config/completions/completions/_fd
Normal file
@ -0,0 +1,273 @@
|
||||
#compdef fd
|
||||
|
||||
##
|
||||
# zsh completion function for fd
|
||||
#
|
||||
# Based on ripgrep completion function.
|
||||
# Originally based on code from the zsh-users project — see copyright notice
|
||||
# below.
|
||||
|
||||
autoload -U is-at-least
|
||||
|
||||
_fd() {
|
||||
local curcontext="$curcontext" no='!' ret=1
|
||||
local -a context line state state_descr _arguments_options fd_types fd_args
|
||||
local -A opt_args
|
||||
|
||||
if is-at-least 5.2; then
|
||||
_arguments_options=( -s -S )
|
||||
else
|
||||
_arguments_options=( -s )
|
||||
fi
|
||||
|
||||
fd_types=(
|
||||
{f,file}'\:"regular files"'
|
||||
{d,directory}'\:"directories"'
|
||||
{l,symlink}'\:"symbolic links"'
|
||||
{e,empty}'\:"empty files or directories"'
|
||||
{x,executable}'\:"executable (files)"'
|
||||
{s,socket}'\:"sockets"'
|
||||
{p,pipe}'\:"named pipes (FIFOs)"'
|
||||
)
|
||||
|
||||
# Do not complete rare options unless either the current prefix
|
||||
# matches one of those options or the user has the `complete-all`
|
||||
# style set. Note that this prefix check has to be updated manually to account
|
||||
# for all of the potential negation options listed below!
|
||||
if
|
||||
# (--[bpsu]* => match all options marked with '$no')
|
||||
[[ $PREFIX$SUFFIX == --[bopsu]* ]] ||
|
||||
zstyle -t ":complete:$curcontext:*" complete-all
|
||||
then
|
||||
no=
|
||||
fi
|
||||
|
||||
# We make heavy use of argument groups here to prevent the option specs from
|
||||
# growing unwieldy. These aren't supported in zsh <5.4, though, so we'll strip
|
||||
# them out below if necessary. This makes the exclusions inaccurate on those
|
||||
# older versions, but oh well — it's not that big a deal
|
||||
fd_args=(
|
||||
+ '(hidden)' # hidden files
|
||||
{-H,--hidden}'[search hidden files/directories]'
|
||||
|
||||
+ '(no-ignore-full)' # all ignore files
|
||||
'(no-ignore-partial)'{-I,--no-ignore}"[don't respect .(git|fd)ignore and global ignore files]"
|
||||
$no'(no-ignore-partial)*'{-u,--unrestricted}'[alias for --no-ignore, when repeated also alias for --hidden]'
|
||||
|
||||
+ no-ignore-partial # some ignore files
|
||||
"(no-ignore-full --no-ignore-vcs)--no-ignore-vcs[don't respect .gitignore files]"
|
||||
"!(no-ignore-full --no-global-ignore-file)--no-global-ignore-file[don't respect the global ignore file]"
|
||||
$no'(no-ignore-full --no-ignore-parent)--no-ignore-parent[]'
|
||||
|
||||
+ '(case)' # case-sensitivity
|
||||
{-s,--case-sensitive}'[perform a case-sensitive search]'
|
||||
{-i,--ignore-case}'[perform a case-insensitive search]'
|
||||
|
||||
+ '(regex-pattern)' # regex-based search pattern
|
||||
'(no-regex-pattern)--regex[perform a regex-based search (default)]'
|
||||
|
||||
+ '(no-regex-pattern)' # non-regex-based search pattern
|
||||
{-g,--glob}'[perform a glob-based search]'
|
||||
{-F,--fixed-strings}'[treat pattern as literal string instead of a regex]'
|
||||
|
||||
+ '(match-full)' # match against full path
|
||||
{-p,--full-path}'[match the pattern against the full path instead of the basename]'
|
||||
|
||||
+ '(follow)' # follow symlinks
|
||||
{-L,--follow}'[follow symbolic links to directories]'
|
||||
|
||||
+ '(abs-path)' # show absolute paths
|
||||
'(long-listing)'{-a,--absolute-path}'[show absolute paths instead of relative paths]'
|
||||
|
||||
+ '(null-sep)' # use null separator for output
|
||||
'(long-listing)'{-0,--print0}'[separate search results by the null character]'
|
||||
|
||||
+ '(long-listing)' # long-listing output
|
||||
'(abs-path null-sep max-results exec-cmds)'{-l,--list-details}'[use a long listing format with file metadata]'
|
||||
|
||||
+ '(max-results)' # max number of results
|
||||
'(long-listing exec-cmds)--max-results=[limit number of search results to given count and quit]:count'
|
||||
'(long-listing exec-cmds)-1[limit to a single search result and quit]'
|
||||
|
||||
+ '(fs-errors)' # file-system errors
|
||||
$no'--show-errors[enable the display of filesystem errors]'
|
||||
|
||||
+ '(fs-traversal)' # file-system traversal
|
||||
$no"--one-file-system[don't descend into directories on other file systems]"
|
||||
'!--mount'
|
||||
'!--xdev'
|
||||
|
||||
+ dir-depth # directory depth
|
||||
'(--exact-depth -d --max-depth)'{-d+,--max-depth=}'[set max directory depth to descend when searching]:depth'
|
||||
'!(--exact-depth -d --max-depth)--maxdepth:depth'
|
||||
'(--exact-depth --min-depth)--min-depth=[set directory depth to descend before start searching]:depth'
|
||||
'(--exact-depth -d --max-depth --maxdepth --min-depth)--exact-depth=[only search at the exact given directory depth]:depth'
|
||||
|
||||
+ prune # pruning
|
||||
"--prune[don't traverse into matching directories]"
|
||||
|
||||
+ filter-misc # filter search
|
||||
'*'{-t+,--type=}"[filter search by type]:type:(($fd_types))"
|
||||
'*'{-e+,--extension=}'[filter search by file extension]:extension'
|
||||
'*'{-E+,--exclude=}'[exclude files/directories that match the given glob pattern]:glob pattern'
|
||||
'*'{-S+,--size=}'[limit search by file size]:size limit:->size'
|
||||
'(-o --owner)'{-o+,--owner=}'[filter by owning user and/or group]:owner and/or group:->owner'
|
||||
|
||||
+ ignore-file # extra ignore files
|
||||
'*--ignore-file=[add a custom, low-precedence ignore-file with .gitignore format]: :_files'
|
||||
|
||||
+ '(filter-mtime-newer)' # filter by files modified after than
|
||||
'--changed-within=[limit search to files/directories modified within the given date/duration]:date or duration'
|
||||
'!--change-newer-than=:date/duration'
|
||||
'!--newer=:date/duration'
|
||||
|
||||
+ '(filter-mtime-older)' # filter by files modified before than
|
||||
'--changed-before=[limit search to files/directories modified before the given date/duration]:date or duration'
|
||||
'!--change-older-than=:date/duration'
|
||||
'!--older=:date/duration'
|
||||
|
||||
+ '(color)' # colorize output
|
||||
{-c+,--color=}'[declare when to colorize search results]:when to colorize:((
|
||||
auto\:"show colors if the output goes to an interactive console (default)"
|
||||
never\:"do not use colorized output"
|
||||
always\:"always use colorized output"
|
||||
))'
|
||||
|
||||
+ '(threads)'
|
||||
{-j+,--threads=}'[set the number of threads for searching and executing]:number of threads'
|
||||
|
||||
+ '(exec-cmds)' # execute command
|
||||
'(long-listing max-results)'{-x+,--exec=}'[execute command for each search result]:command: _command_names -e:*\;::program arguments: _normal'
|
||||
'(long-listing max-results)'{-X+,--exec-batch=}'[execute command for all search results at once]:command: _command_names -e:*\;::program arguments: _normal'
|
||||
'(long-listing max-results)--batch-size=[max number of args for each -X call]:size'
|
||||
|
||||
+ other
|
||||
'!(--max-buffer-time)--max-buffer-time=[set amount of time to buffer before showing output]:time (ms)'
|
||||
|
||||
+ '(about)' # about flags
|
||||
'(: * -)'{-h,--help}'[display help message]'
|
||||
'(: * -)'{-v,--version}'[display version information]'
|
||||
|
||||
+ path-sep # set path separator for output
|
||||
$no'(--path-separator)--path-separator=[set the path separator to use when printing file paths]:path separator'
|
||||
|
||||
+ search-path
|
||||
$no'(--base-directory)--base-directory=[change the current working directory to the given path]:directory:_files -/'
|
||||
$no'(*)*--search-path=[set search path (instead of positional <path> arguments)]:directory:_files -/'
|
||||
|
||||
+ strip-cwd-prefix
|
||||
$no'(strip-cwd-prefix exec-cmds)--strip-cwd-prefix[Strip ./ prefix when output is redirected]'
|
||||
|
||||
+ args # positional arguments
|
||||
'1: :_guard "^-*" pattern'
|
||||
'(--search-path)*:directory:_files -/'
|
||||
)
|
||||
|
||||
# Strip out argument groups where unsupported (see above)
|
||||
is-at-least 5.4 ||
|
||||
fd_args=( ${(@)args:#(#i)(+|[a-z0-9][a-z0-9_-]#|\([a-z0-9][a-z0-9_-]#\))} )
|
||||
|
||||
_arguments $_arguments_options : $fd_args && ret=0
|
||||
|
||||
case ${state} in
|
||||
owner)
|
||||
compset -P '(\\|)\!'
|
||||
if compset -P '*:'; then
|
||||
_groups && ret=0
|
||||
else
|
||||
if
|
||||
compset -S ':*' ||
|
||||
# Do not add the colon suffix when completing "!user<TAB>
|
||||
# (with a starting double-quote) otherwise pressing tab again
|
||||
# after the inserted colon "!user:<TAB> will complete history modifiers
|
||||
[[ $IPREFIX == (\\|\!)* && ($QIPREFIX == \"* && -z $QISUFFIX) ]]
|
||||
then
|
||||
_users && ret=0
|
||||
else
|
||||
local q
|
||||
# Since quotes are needed when using the negation prefix !,
|
||||
# automatically remove the colon suffix also when closing the quote
|
||||
if [[ $QIPREFIX == [\'\"]* ]]; then
|
||||
q=${QIPREFIX:0:1}
|
||||
fi
|
||||
_users -r ": \t\n\-$q" -S : && ret=0
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
size)
|
||||
if compset -P '[-+][0-9]##'; then
|
||||
local -a suff=(
|
||||
'B:bytes'
|
||||
'K:kilobytes (10^3 = 1000 bytes)'
|
||||
'M:megabytes (10^6 = 1000^2 bytes)'
|
||||
'G:gigabytes (10^9 = 1000^3 bytes)'
|
||||
'T:terabytes (10^12 = 1000^4 bytes)'
|
||||
'Ki:kibibytes ( 2^10 = 1024 bytes)'
|
||||
'Mi:mebibytes ( 2^20 = 1024^2 bytes)'
|
||||
'Gi:gigibytes ( 2^30 = 1024^3 bytes)'
|
||||
'Ti:tebibytes ( 2^40 = 1024^4 bytes)'
|
||||
)
|
||||
_describe -t units 'size limit units' suff -V 'units'
|
||||
elif compset -P '[-+]'; then
|
||||
_message -e 'size limit number (full format: <+-><number><unit>)'
|
||||
else
|
||||
_values 'size limit prefix (full format: <prefix><number><unit>)' \
|
||||
'\+[file size must be greater or equal to]'\
|
||||
'-[file size must be less than or equal to]' && ret=0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_fd "$@"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2011 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 fd
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * smancill (https://github.com/smancill)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# coding: utf-8-unix
|
||||
# indent-tabs-mode: nil
|
||||
# sh-indentation: 2
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
338
.config/zsh/config/completions/completions/_firewalld
Normal file
338
.config/zsh/config/completions/completions/_firewalld
Normal file
@ -0,0 +1,338 @@
|
||||
#compdef firewall-cmd firewall-offline-cmd
|
||||
|
||||
local curcontext="$curcontext" name nm="$compstate[nmatches]"
|
||||
local -a state line expl direct args auxargs opargs suf
|
||||
typeset -A opt_args
|
||||
|
||||
direct=(
|
||||
'--get-all-chains[get all chains]'
|
||||
'--get-chains[get all chains added to the table]:family:(ipv4 ipv6 eb):table:->tables'
|
||||
'--add-chain[add a new chain to the table]:family:(ipv4 ipv6 eb):table:->tables:new chain'
|
||||
'--remove-chain[remove a chain from the table]:family:(ipv4 ipv6 eb):table:->tables:chain:->chains'
|
||||
'--query-chain[return whether the chain has been added to the table]:family:(ipv4 ipv6 eb):table:->tables:chain:->chains'
|
||||
'--get-all-rules[get all rules]'
|
||||
'--get-rules[get all rules added to chain in table]:family:(ipv4 ipv6 eb):table:->tables:chain:->chains'
|
||||
'--add-rule[add rule to chain in table]:family:(ipv4 ipv6 eb):table:->tables:chain:->chains:priority: :*:argument'
|
||||
'--remove-rule[remove rule with priority from chain in table]:family:(ipv4 ipv6 eb):table:->tables:chain:->chains:priority: :*:argument'
|
||||
'--remove-rules[remove rules from chain in table]:family:(ipv4 ipv6 eb):table:->tables:chain->chains'
|
||||
'--query-rule[chain in table]:family:(ipv4 ipv6 eb):table:->tables:chain: :priority: :*:argument'
|
||||
'--get-all-passthroughs[get all tracked passthrough rules]'
|
||||
'--get-passthroughs[get tracked passthrough rules]:family:(ipv4 ipv6 eb):*:: : _iptables'
|
||||
'--add-passthrough[add a new tracked passthrough rule]:family:(ipv4 ipv6 eb):*:: : _iptables'
|
||||
'--remove-passthrough[remove a tracked passthrough rule]:family:(ipv4 ipv6 eb):*:: : _iptables'
|
||||
'--query-passthrough[return whether the tracked passthrough rule has been added]:family:(ipv4 ipv6 eb):*:: : _iptables'
|
||||
)
|
||||
name='--name=[specify new name]:name'
|
||||
|
||||
case $service in
|
||||
firewall-cmd)
|
||||
direct+=(
|
||||
'--passthrough[pass a command through (untracked by firewalld)]:family:(ipv4 ipv6 eb):*:: : _iptables'
|
||||
)
|
||||
args=(
|
||||
'(--timeout)--permanent[set an option permanently]'
|
||||
)
|
||||
auxargs=(
|
||||
'(--permanent)--timeout=[specify time for rule to be active]:time value (seconds)'
|
||||
)
|
||||
opargs=(
|
||||
'(aux --permanent --zone)--state[print firewalld state]'
|
||||
'(aux --permanent --zone)--reload[reload firewall and keep state information]'
|
||||
'(aux --permanent --zone)--complete-reload[reload firewall and lose state information]'
|
||||
'(aux --permanent --zone)--runtime-to-permanent[create permanent from runtime configuration]'
|
||||
'(aux --permanent --zone -q --quiet)--get-active-zones[print currently active zones]'
|
||||
'*--remove-service=[remove a service from a zone]:service:->services'
|
||||
'(aux --permanent --zone)--panic-on[enable panic mode]'
|
||||
'(aux --permanent --zone)--panic-off[disable panic mode]'
|
||||
'(aux --permanent --zone)--query-panic[query whether panic mode is enabled]'
|
||||
)
|
||||
;;
|
||||
firewall-offline-cmd)
|
||||
args=(
|
||||
'--system-config[specify path to firewalld system configuration]:path:_directories'
|
||||
'--default-config[specify path to firewalld default configuration]:path:_directories'
|
||||
'--migrate-system-config-firewall=[import configuration data from the given configuration file]:file:_files'
|
||||
'--disabled[disable the firewall by disabling the firewalld service]' '!(--disabled)--enabled'
|
||||
'!--'{add,remove}'module=:iptables module' '!--custom-rules=:type:table:filename (ignored'
|
||||
\*{-s+,--service=}'[enable a service in the default zone]:service:->services'
|
||||
'*--remove-service=[disable a service in the default zone]:service:->services'
|
||||
\*{-p+,--port=}'[enable a port in the default zone]:port:->ports'
|
||||
\*{-t+,--trust=}'[bind an interface to the trusted zone]:interface:_net_interfaces'
|
||||
{-m+,--masq=}'[enable masquerading in the default zone, IPv4 only]:interface (ignored)'
|
||||
'--forward-port=[add port forward in the default zone]:port forward:->port-forwards'
|
||||
'--block-icmp=[block this ICMP type in the default zone]:icmp type:->icmp-types'
|
||||
"--policy-server[change Polkit actions to 'server' (more restricted)]"
|
||||
"--policy-desktop[change Polkit actions to 'desktop' (less restricted)]"
|
||||
)
|
||||
opargs=(
|
||||
'*--remove-service-from-zone[remove a service from a zone]:service:->services'
|
||||
)
|
||||
;;
|
||||
esac
|
||||
|
||||
# option ordering doesn't matter but listing fewer options makes
|
||||
# completion more useful:
|
||||
(( $words[(I)--direct] )) || direct=( \!$^direct ) # only list direct options after --direct
|
||||
(( $words[(I)--new-*-from-file*] )) || name="!$name" # also check for required options before listing --name
|
||||
|
||||
_arguments -C -s $args $direct \
|
||||
'!(-q --quiet)'{-v,--verbose} \
|
||||
'(-q --quiet --list-all --list-all-zones --list-lockdown-whitelist-commands --list-lockdown-whitelist-contexts --list-lockdown-whitelist-uids --list-lockdown-whitelist-users --list-services --list-ports --list-protocols --list-icmp-blocks --list-forward-ports --list-rich-rules --list-interfaces --list-sources --get-default-zone --get-active-zones --get-zone-of-interface --get-zone-of-source --get-zones --get-services --get-icmptypes --get-target --info-zone --info-icmptype --info-service --info-ipset --get-ipsets --get-entries --info-helper --get-helpers --get-destinations --get-description --version -h --help)'{-q,--quiet}"[don't print status messages]" \
|
||||
'*--zone=[use this zone to set or query options, else default zone]:zone:->zones' \
|
||||
+ aux \
|
||||
$auxargs $name \
|
||||
'*--option=[specify option]:option (key=value)' \
|
||||
'--type=[specify ipset type]:ipset type:->ipset-types' \
|
||||
'--ipset=[specify ipset]:ipset:->ipsets' \
|
||||
'--icmptype=[specify icmp type]:icmp type:->icmp-types' \
|
||||
'--service=[specify service]:service:->services' \
|
||||
'--helper=[specify helper]:helper:->helpers' \
|
||||
'--family=[specify family]:family:(ipv4 ipv6)' \
|
||||
'--module=[specify module]:module' \
|
||||
+ '(op)' \
|
||||
$opargs \
|
||||
'(aux -)'{-h,--help}'[display usage information]' \
|
||||
'(aux -)'{-V,--version}'[display version information]' \
|
||||
'(aux --permanent --zone)--get-log-denied[print the log denied value]' \
|
||||
'(aux --permanent --zone)--set-log-denied=[set log denied value]:value:(all unicast broadcast multicast off)' \
|
||||
'(aux --permanent --zone)--get-automatic-helpers[print the automatic helpers value]' \
|
||||
'(aux --permanent --zone)--set-automatic-helpers=[set automatic helpers value]:value:(yes no system)' \
|
||||
'(aux --permanent --zone -q --quiet)--get-default-zone[print default zone for connections and interfaces]' \
|
||||
'(aux --permanent --zone)--set-default-zone=[set default zone]:zone:->zones' \
|
||||
'(--zone -q --quiet)--get-zones[print predefined zones]' \
|
||||
'(--zone -q --quiet)--get-services[print predefined services]' \
|
||||
'(--zone -q --quiet)--get-icmptypes[print predefined icmptypes]' \
|
||||
'(-q --quiet)*--get-zone-of-interface=[print name of the zone the interface is bound to]:interface:_net_interfaces' \
|
||||
'(-q --quiet)*--get-zone-of-source=[print name of the zone a source is bound to]:source' \
|
||||
'(-q --quiet)--list-all-zones[list everything added for or enabled in all zones]' \
|
||||
'--new-zone=[add a new zone]:zone:->zones' \
|
||||
'--new-zone-from-file=[add a new zone from file with optional name]:filename:_files' \
|
||||
'--delete-zone=[delete an existing zone]:zone:->zones' \
|
||||
'--load-zone-defaults=[load zone default settings]:zone:->zones' \
|
||||
'(-q --quiet)--get-target[get the zone target]' \
|
||||
'--set-target=[set the zone target]:target:(default ACCEPT DROP REJECT)' \
|
||||
'(-q --quiet)--info-zone=[print information about a zone]:zone:->zones' \
|
||||
'--path-zone=[print file path of a zone]:zone:->zones' \
|
||||
'(aux --permanent --zone)--get-ipset-types[print the supported ipset types]' \
|
||||
'--new-ipset=[add a new ipset]:ipset:->ipsets' \
|
||||
'--new-ipset-from-file=[add a new ipset from file with optional name]:filename:_files' \
|
||||
'--delete-ipset=[delete an existing ipset]:ipset:->ipsets' \
|
||||
'--load-ipset-defaults=[load ipset default settings]:ipset:->ipsets' \
|
||||
'(-q --quiet)--info-ipset=[print information about an ipset]:ipset' \
|
||||
'--path-ipset=[print file path of an ipset]:ipset' \
|
||||
'(aux --permanent --zone -q --quiet)--get-ipsets[print predefined ipsets]' \
|
||||
'--set-description=[set new description]:description' \
|
||||
'(-q --quiet)--get-description[print description]' \
|
||||
'--set-short=[set new short description]:description' \
|
||||
'--get-short[print short description]' \
|
||||
'*--add-entry=[add a new entry to an ipset]:entry' \
|
||||
'*--remove-entry=[remove an entry from an ipset]:entry' \
|
||||
'*--query-entry=[return whether ipset has an entry]:entry' \
|
||||
'(-q --quiet)--get-entries[list entries of an ipset]' \
|
||||
'*--add-entries-from-file=[add a new entries to an ipset]:entry' \
|
||||
'--remove-entries-from-file=[remove entries from an ipset]:entry' \
|
||||
'--new-icmptype=[add a new icmptype]:icmp type:->icmp-types' \
|
||||
'--new-icmptype-from-file=[add a new icmptype from file with optional name]:file:_files' \
|
||||
'--delete-icmptype=[delete an existing icmptype]:icmp type:->icmp-types' \
|
||||
'--load-icmptype-defaults=[load icmptype default settings]:icmp type:->icmp-types' \
|
||||
'(-q --quiet)--info-icmptype=[print information about an icmptype]:icmp type:->icmp-types' \
|
||||
'--path-icmptype=[print file path of an icmptype]:icmp type:->icmp-types' \
|
||||
'*--add-destination=[enable destination for ipv in icmptype]:destination:->destinations' \
|
||||
'*--remove-destination=[disable destination for ipv in service or icmp-type]:destination:->destinations' \
|
||||
'(-q --quiet)--get-destinations[list destinations]' \
|
||||
'--new-service=[add a new service]:service' \
|
||||
'--new-service-from-file=[add a new service from file with optional name]:file:_files' \
|
||||
'--delete-service=[delete an existing service]:service:->services' \
|
||||
'--load-service-defaults=[load icmptype default settings]:service:->services' \
|
||||
'(-q --quiet)--info-service=[print information about a service]:service:->services' \
|
||||
'--path-service=[print file path of a service]:service:->services' \
|
||||
'*--add-port=[add a new port to service, zone or helper]:port:->ports' \
|
||||
'*--remove-port=[remove a port from a service, zone or helper]:port:->ports' \
|
||||
'*--query-port=[return whether the port has been added for service, zone or helper]:port:->ports' \
|
||||
'--get-ports[list ports of service or helper]' \
|
||||
'*--add-protocol=[add a new protocol to service or zone]:protocol' \
|
||||
'*--remove-protocol=[remove a protocol from service or zone]:protocol' \
|
||||
'*--query-protocol=[return whether the protocol has been added for service or zone]:protocol' \
|
||||
'--get-protocols[list protocols of service]' \
|
||||
'*--add-source-port=[add a new source port to service or zone]:port:->ports' \
|
||||
'*--remove-source-port=[remove a source port from service or zone]:port:->ports' \
|
||||
'*--query-source-port=[return whether the source port has been added for service or zone]:port:->ports' \
|
||||
'--get-source-ports[list source ports of service]' \
|
||||
'*--add-module=[add a new module to service]:module' \
|
||||
'*--remove-module=[remove a module from service]:module' \
|
||||
'*--query-module=[return whether the module has been added for service]:module' \
|
||||
'--get-modules[list modules of service]' \
|
||||
'*--set-destination=[set destination for ipv to address in service]:destination:->destinations' \
|
||||
'--query-destination=[return whether destination ipv is set for service or enabled for icmptype]:destination:->destinations' \
|
||||
'(-q --quiet)--list-all[list everything added for or enabled in a zone]' \
|
||||
'(-q --quiet)--list-services[list services added for a zone]' \
|
||||
'*--add-service=[add a service for a zone]:service:->services' \
|
||||
'*--query-service=[return whether service has been added for a zone]:service:->services' \
|
||||
'(-q --quiet)--list-ports[list ports added for a zone]' \
|
||||
'(-q --quiet)--list-protocols[list protocols added for a zone]' \
|
||||
'--list-source-ports[list source ports added for a zone]' \
|
||||
'(-q --quiet)--list-icmp-blocks[list Internet ICMP type blocks added for a zone]' \
|
||||
'*--add-icmp-block=[add an ICMP block for a zone]:icmp type:->icmp-types' \
|
||||
'*--remove-icmp-block=[remove the ICMP block from a zone]:icmp type:->icmp-types' \
|
||||
'*--query-icmp-block=[return whether an ICMP block has been added for a zone]:icmp type:->icmp-types' \
|
||||
'--add-icmp-block-inversion[enable inversion of icmp blocks for a zone]' \
|
||||
'--remove-icmp-block-inversion[disable inversion of icmp blocks for a zone]' \
|
||||
'--query-icmp-block-inversion[return whether inversion of icmp blocks has been enabled for a zone]' \
|
||||
'(-q --quiet)--list-forward-ports[list IPv4 forward ports added for a zone]' \
|
||||
'*--add-forward-port=[add the IPv4 forward port for a zone]: :->port-forwards' \
|
||||
'*--remove-forward-port=[remove the IPv4 forward port from a zone]: :->port-forwards' \
|
||||
'*--query-forward-port=[return whether the IPv4 forward port has been added for a zone]: :->port-forwards' \
|
||||
'--add-forward[enable forwarding between interfaces and sources in a zone]' \
|
||||
'--remove-forward[disable forwarding between interfaces and sources in a zone]' \
|
||||
'--query-forward[return whether forwarding has been enabled for a zone]' \
|
||||
'--add-masquerade[enable IPv4 masquerade for a zone]' \
|
||||
'--remove-masquerade[disable IPv4 masquerade for a zone]' \
|
||||
'--query-masquerade[return whether IPv4 masquerading has been enabled for a zone]' \
|
||||
'(-q --quiet)--list-rich-rules[list rich language rules added for a zone]' \
|
||||
'*--add-rich-rule=[add rich language rule for a zone]:rule' \
|
||||
'*--remove-rich-rule=[remove specified rich language rule from a zone]:rule' \
|
||||
'*--query-rich-rule=[return whether specified rich language rule has been added for a zone]:rule' \
|
||||
'(-q --quiet)--list-interfaces[list interfaces that are bound to a zone]' \
|
||||
'*--add-interface=[bind the specified interface to a zone]:interface:_net_interfaces' \
|
||||
'*--change-interface=[change zone the specified interface is bound to]:interface:_net_interfaces' \
|
||||
'*--query-interface=[query whether specified interface is bound to a zone]:interface:_net_interfaces' \
|
||||
'*--remove-interface=[remove binding of specified interface from a zone]:interface:_net_interfaces' \
|
||||
'(-q --quiet)--list-sources[list sources that are bound to a zone]' \
|
||||
'*--add-source=[bind source to a zone]: :->sources' \
|
||||
'*--change-source=[change zone a source is bound to]: :->sources' \
|
||||
'*--query-source=[query whether source is bound to a zone]: :->sources' \
|
||||
'*--remove-source=[remove binding of a source from a zone]: :->sources' \
|
||||
'--new-helper=[add a new helper]:helper:->helpers' \
|
||||
'--new-helper-from-file=[add a new helper from file with optional name]:file:_files' \
|
||||
'--delete-helper=[delete an existing helper]:helper:->helpers' \
|
||||
'--load-helper-defaults=[load helper default settings]:helper:->helpers' \
|
||||
'(--zone -q --quiet)--info-helper=[print information about an helper]:helper:->helpers' \
|
||||
'--path-helper=[print file path of an helper]:helper:->helpers' \
|
||||
'--get-policies[print predefined policies]' \
|
||||
'--get-active-policies[print currently active policies]' \
|
||||
'--list-all-policies[list everything added for or enabled in all policies]' \
|
||||
'--new-policy=[add a new empty policy]:policy:->policies' \
|
||||
'--new-policy-from-file=[add a new policy from file with optional name override]:file:_files' \
|
||||
'--delete-policy=[delete an existing policy]:policy:->policies' \
|
||||
'--load-policy-defaults=[load policy default settings]:policy:->policies' \
|
||||
'--policy=[use this policy to set or query options]:policy:->policies' \
|
||||
'--info-policy=[print information about a policy]:policy:->policies' \
|
||||
'--path-policy=[print file path of a policy]:policy:->policies' \
|
||||
'(--zone -q --quiet)--get-helpers[print predefined helpers]' \
|
||||
'--set-module=[set module to helper]:module' \
|
||||
'--get-module[get module from helper]' \
|
||||
'--set-family=[set family for helper]:family' \
|
||||
'--get-family[get family from helper]' \
|
||||
'(aux --permanent --zone)--lockdown-on[enable lockdown]' \
|
||||
'(aux --permanent --zone)--lockdown-off[disable lockdown]' \
|
||||
'(aux --permanent --zone)--query-lockdown[query whether lockdown is enabled]' \
|
||||
'(-q --quiet)--list-lockdown-whitelist-commands[list all command lines that are on the whitelist]' \
|
||||
'*--add-lockdown-whitelist-command=[add a command to the whitelist]:command:_cmdstring' \
|
||||
'*--remove-lockdown-whitelist-command=[remove the command from the whitelist]:command' \
|
||||
'*--query-lockdown-whitelist-command=[query whether a command is on the whitelist]:command' \
|
||||
'(-q --quiet)--list-lockdown-whitelist-contexts[list all contexts that are on the whitelist]' \
|
||||
'*--add-lockdown-whitelist-context=[add the specified context to the whitelist]:context' \
|
||||
'*--remove-lockdown-whitelist-context=[remove a context from the whitelist]:context' \
|
||||
'*--query-lockdown-whitelist-context=[query whether a context is on the whitelist]:context' \
|
||||
'(-q --quiet)--list-lockdown-whitelist-uids[list all user ids that are on the whitelist]' \
|
||||
'*--add-lockdown-whitelist-uid=[add the specified user id to the whitelist]:uid' \
|
||||
'*--remove-lockdown-whitelist-uid=[remove the specified user id from the whitelist]:uid' \
|
||||
'*--query-lockdown-whitelist-uid=[query whether a user id is on the whitelist]:uid' \
|
||||
'(-q --quiet)--list-lockdown-whitelist-users[list all user names that are on the whitelist]' \
|
||||
'*--add-lockdown-whitelist-user=[add the specified user to the whitelist]:user:_users' \
|
||||
'*--remove-lockdown-whitelist-user=[remove the specified user from the whitelist]:user:_users' \
|
||||
'*--query-lockdown-whitelist-user=[query whether the specified user is on the whitelist]:user:_users' \
|
||||
'--direct[first option for all direct options]'
|
||||
|
||||
|
||||
# add sub option for policy.
|
||||
if [[ ${words[@]/'--policy'/} != ${words[@]} ]]
|
||||
then
|
||||
_arguments \
|
||||
'--get-priority[get the priority]' \
|
||||
'--set-priority=[set the priority]' \
|
||||
'--list-ingress-zones[list ingress zones that are bound to a policy]' \
|
||||
'--add-ingress-zone=[add the ingress zone to a policy]:zone:->zones' \
|
||||
'--remove-ingress-zone=[remove the ingress zone from a policy]:zone:->zones' \
|
||||
'--query-ingress-zone=[wuery whether the ingress zone has been adedd to a policy]:zone:->zones' \
|
||||
'--list-egress-zones[list egress zones that are bound to a policy]' \
|
||||
'--add-egress-zone=[add the egress zone to a policy]:zone:->zones' \
|
||||
'--remove-egress-zone=[remove the egress zone from a policy]:zone:->zones' \
|
||||
'--query-egress-zone=[query whether the egress zone has been adedd to a policy]:zone:->zones'
|
||||
fi
|
||||
|
||||
[[ $state = sources ]] && compset -P 'ipset:' && state=ipsets
|
||||
case $state in
|
||||
sources)
|
||||
_message -e sources "source[/mask]|MAC|ipset:ipset"
|
||||
;;
|
||||
chains)
|
||||
_description chains expl 'chain'
|
||||
compadd "$expl[@]" - ${${(f)"$(_call_program chains $words[1] ${(k)opt_args[--permanent]} --direct --get-all-chains)"}##* }
|
||||
;;
|
||||
destinations)
|
||||
if compset -P 1 '*:'; then
|
||||
if compset -P 1 '*/'; then
|
||||
_message -e masks "mask"
|
||||
else
|
||||
_message -e addresses "address"
|
||||
fi
|
||||
else
|
||||
compset -S ':*' || suf=( -qS : )
|
||||
_description ipvs expl 'ipv'
|
||||
compadd "$expl[@]" $suf - ipv4 ipv6
|
||||
fi
|
||||
;;
|
||||
helpers)
|
||||
_description helpers expl 'helper'
|
||||
compadd "$expl[@]" - $(_call_program helpers $words[1] ${(k)opt_args[--permanent]} --get-helpers)
|
||||
;;
|
||||
icmp-types)
|
||||
_description icmp-types expl 'icmp type'
|
||||
compadd "$expl[@]" - $(_call_program icmp-types $words[1] --get-icmptypes)
|
||||
;;
|
||||
ipsets)
|
||||
_description ipsets expl 'ipset'
|
||||
compadd "$expl[@]" - $(_call_program ipsets $words[1] ${(k)opt_args[--permanent]} --get-ipsets)
|
||||
;;
|
||||
ipset-types)
|
||||
_description ipset-types expl 'ipset type'
|
||||
compadd "$expl[@]" - $(_call_program ipset-types $words[1] --get-ipset-types)
|
||||
;;
|
||||
ports)
|
||||
if compset -P 1 '*/'; then
|
||||
_description protocols expl 'protocol'
|
||||
compadd "$expl[@]" - tcp udp sctp dccp
|
||||
else
|
||||
_message -e ports 'port number'
|
||||
fi
|
||||
;;
|
||||
port-forwards)
|
||||
_values -S = -s : 'port forward' \
|
||||
'port[specify port]:port range:_sequence -n 2 -s - _ports' \
|
||||
'proto[specify protocol]:protocol:(tcp udp sctp dccp)' \
|
||||
'toport[specify port]:port range:_sequence -n 2 -s - _ports' \
|
||||
'toaddr[specify destination address]:address[/mask]'
|
||||
;;
|
||||
services)
|
||||
_description services expl 'service'
|
||||
compadd "$expl[@]" - $(_call_program services $words[1] --get-services)
|
||||
;;
|
||||
tables)
|
||||
_description services expl 'service'
|
||||
compadd "$expl[@]" - security raw mangle nat filter
|
||||
;;
|
||||
zones)
|
||||
_description zones expl 'zone'
|
||||
compadd "$expl[@]" - $(_call_program zones $words[1] --get-zones)
|
||||
;;
|
||||
policies)
|
||||
_description policies expl 'policies'
|
||||
compadd "$expl[@]" - $(_call_program policies $words[1] --get-policies)
|
||||
;;
|
||||
esac
|
||||
|
||||
# return whether matches were added
|
||||
[[ nm -ne compstate[nmatches] ]] && return 0
|
||||
return 1
|
||||
|
1034
.config/zsh/config/completions/completions/_golang
Normal file
1034
.config/zsh/config/completions/completions/_golang
Normal file
File diff suppressed because it is too large
Load Diff
6
.config/zsh/config/completions/completions/_j
Normal file
6
.config/zsh/config/completions/completions/_j
Normal file
@ -0,0 +1,6 @@
|
||||
#compdef j
|
||||
cur=${words[2, -1]}
|
||||
|
||||
autojump --complete ${=cur[*]} | while read i; do
|
||||
compadd -U "$i";
|
||||
done
|
1
.config/zsh/config/completions/completions/_kubectl
Normal file
1
.config/zsh/config/completions/completions/_kubectl
Normal file
@ -0,0 +1 @@
|
||||
source <(kubectl completion zsh)
|
1
.config/zsh/config/completions/completions/_minikube
Normal file
1
.config/zsh/config/completions/completions/_minikube
Normal file
@ -0,0 +1 @@
|
||||
source <(minikube completion zsh)
|
250
.config/zsh/config/completions/completions/_mpv
Normal file
250
.config/zsh/config/completions/completions/_mpv
Normal file
@ -0,0 +1,250 @@
|
||||
#compdef mpv
|
||||
|
||||
# ZSH completion for mpv
|
||||
#
|
||||
# For customization, see:
|
||||
# https://github.com/mpv-player/mpv/wiki/Zsh-completion-customization
|
||||
|
||||
#
|
||||
# This file is part of mpv.
|
||||
#
|
||||
# mpv is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# mpv is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
local curcontext="$curcontext" state state_descr line
|
||||
typeset -A opt_args
|
||||
|
||||
local -a match mbegin mend
|
||||
local MATCH MBEGIN MEND
|
||||
|
||||
# By default, don't complete URLs unless no files match
|
||||
local -a tag_order
|
||||
zstyle -a ":completion:*:*:$service:*" tag-order tag_order ||
|
||||
zstyle ":completion:*:*:$service:*" tag-order '!urls'
|
||||
|
||||
typeset -ga _mpv_completion_arguments _mpv_completion_protocols
|
||||
|
||||
function _mpv_generate_arguments {
|
||||
|
||||
_mpv_completion_arguments=()
|
||||
|
||||
local -a option_aliases=()
|
||||
|
||||
local list_options_line
|
||||
for list_options_line in "${(@f)$($~words[1] --list-options)}"; do
|
||||
|
||||
[[ $list_options_line =~ $'^[ \t]+--([^ \t]+)[ \t]*(.*)' ]] || continue
|
||||
|
||||
local name=$match[1] desc=$match[2]
|
||||
|
||||
if [[ $desc == Flag* ]]; then
|
||||
|
||||
_mpv_completion_arguments+="$name"
|
||||
if [[ $name != (\{|\}|v|list-options) ]]; then
|
||||
# Negated version
|
||||
_mpv_completion_arguments+="no-$name"
|
||||
fi
|
||||
|
||||
elif [[ -z $desc ]]; then
|
||||
|
||||
# Sub-option for list option
|
||||
|
||||
if [[ $name == *-(clr|help) ]]; then
|
||||
# Like a flag
|
||||
_mpv_completion_arguments+="$name"
|
||||
else
|
||||
# Find the parent option and use that with this option's name
|
||||
_mpv_completion_arguments+="${_mpv_completion_arguments[(R)${name%-*}=*]/*=/$name=}"
|
||||
fi
|
||||
|
||||
elif [[ $desc == Print* ]]; then
|
||||
|
||||
_mpv_completion_arguments+="$name"
|
||||
|
||||
elif [[ $desc =~ $'^alias for (--)?([^ \t]+)' ]]; then
|
||||
|
||||
# Save this for later; we might not have parsed the target option yet
|
||||
option_aliases+="$name $match[2]"
|
||||
|
||||
else
|
||||
|
||||
# Option takes argument
|
||||
|
||||
local entry="$name=-:${desc//:/\\:}:"
|
||||
|
||||
if [[ $desc =~ '^Choices: ([^(]*)' ]]; then
|
||||
|
||||
local -a choices=(${(s: :)match[1]})
|
||||
entry+="($choices)"
|
||||
# If "no" is one of the choices, it can also be negated like a flag
|
||||
# (--no-whatever is equivalent to --whatever=no).
|
||||
if (( ${+choices[(r)no]} )); then
|
||||
_mpv_completion_arguments+="no-$name"
|
||||
fi
|
||||
|
||||
elif [[ $desc == *'[file]'* ]]; then
|
||||
|
||||
entry+='->files'
|
||||
|
||||
elif [[ $name == (ao|vo|af|vf|profile|audio-device|vulkan-device) ]]; then
|
||||
|
||||
entry+="->parse-help-$name"
|
||||
|
||||
elif [[ $name == show-profile ]]; then
|
||||
|
||||
entry+="->parse-help-profile"
|
||||
|
||||
fi
|
||||
|
||||
_mpv_completion_arguments+="$entry"
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# Process aliases
|
||||
local to_from real_name arg_spec
|
||||
for to_from in $option_aliases; do
|
||||
# to_from='alias-name real-name'
|
||||
real_name=${to_from##* }
|
||||
for arg_spec in "$real_name" "$real_name=*" "no-$real_name"; do
|
||||
arg_spec=${_mpv_completion_arguments[(r)$arg_spec]}
|
||||
[[ -n $arg_spec ]] &&
|
||||
_mpv_completion_arguments+="${arg_spec/$real_name/${to_from%% *}}"
|
||||
done
|
||||
done
|
||||
|
||||
# Older versions of zsh have a bug where they won't complete an option listed
|
||||
# after one that's a prefix of it. To work around this, we can sort the
|
||||
# options by length, longest first, so that any prefix of an option will be
|
||||
# listed after it. On newer versions of zsh where the bug is fixed, we skip
|
||||
# this to avoid slowing down the first tab press any more than we have to.
|
||||
autoload -Uz is-at-least
|
||||
if ! is-at-least 5.2; then
|
||||
# If this were a real language, we wouldn't have to sort by prepending the
|
||||
# length, sorting the whole thing numerically, and then removing it again.
|
||||
local -a sort_tmp=()
|
||||
for arg_spec in $_mpv_completion_arguments; do
|
||||
sort_tmp+=${#arg_spec%%=*}_$arg_spec
|
||||
done
|
||||
_mpv_completion_arguments=(${${(On)sort_tmp}/#*_})
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function _mpv_generate_protocols {
|
||||
_mpv_completion_protocols=()
|
||||
local list_protos_line
|
||||
for list_protos_line in "${(@f)$($~words[1] --list-protocols)}"; do
|
||||
if [[ $list_protos_line =~ $'^[ \t]+(.*)' ]]; then
|
||||
_mpv_completion_protocols+="$match[1]"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function _mpv_generate_if_changed {
|
||||
# Called with $1 = 'arguments' or 'protocols'. Generates the respective list
|
||||
# on the first run and re-generates it if the executable being completed for
|
||||
# is different than the one we used to generate the cached list.
|
||||
typeset -gA _mpv_completion_binary
|
||||
local current_binary=${~words[1]:c}
|
||||
zmodload -F zsh/stat b:zstat
|
||||
current_binary+=T$(zstat +mtime $current_binary)
|
||||
if [[ $_mpv_completion_binary[$1] != $current_binary ]]; then
|
||||
# Use PCRE for regular expression matching if possible. This approximately
|
||||
# halves the execution time of generate_arguments compared to the default
|
||||
# POSIX regex, which translates to a more responsive first tab press.
|
||||
# However, we can't rely on PCRE being available, so we keep all our
|
||||
# patterns POSIX-compatible.
|
||||
zmodload -s -F zsh/pcre C:pcre-match && setopt re_match_pcre
|
||||
_mpv_generate_$1
|
||||
_mpv_completion_binary[$1]=$current_binary
|
||||
fi
|
||||
}
|
||||
|
||||
# Only consider generating arguments if the argument being completed looks like
|
||||
# an option. This way, the user should never see a delay when just completing a
|
||||
# filename.
|
||||
if [[ $words[$CURRENT] == -* ]]; then
|
||||
_mpv_generate_if_changed arguments
|
||||
fi
|
||||
|
||||
local rc=1
|
||||
|
||||
_arguments -C -S \*--$_mpv_completion_arguments '*:files:->mfiles' && rc=0
|
||||
|
||||
case $state in
|
||||
|
||||
parse-help-*)
|
||||
local option_name=${state#parse-help-}
|
||||
# Can't do non-capturing groups without pcre, so we index the ones we want
|
||||
local pattern name_group=1 desc_group=2
|
||||
case $option_name in
|
||||
audio-device|vulkan-device)
|
||||
pattern=$'^[ \t]+'\''([^'\'']*)'\'$'[ \t]+''\((.*)\)'
|
||||
;;
|
||||
profile)
|
||||
# The generic pattern would actually work in most cases for --profile,
|
||||
# but would break if a profile name contained spaces. This stricter one
|
||||
# only breaks if a profile name contains tabs.
|
||||
pattern=$'^\t([^\t]*)\t(.*)'
|
||||
;;
|
||||
*)
|
||||
pattern=$'^[ \t]+(--'${option_name}$'=)?([^ \t]+)[ \t]*[-:]?[ \t]*(.*)'
|
||||
name_group=2 desc_group=3
|
||||
;;
|
||||
esac
|
||||
local -a values
|
||||
local current
|
||||
for current in "${(@f)$($~words[1] --${option_name}=help)}"; do
|
||||
[[ $current =~ $pattern ]] || continue;
|
||||
local name=${match[name_group]//:/\\:} desc=${match[desc_group]}
|
||||
if [[ -n $desc ]]; then
|
||||
values+="${name}:${desc}"
|
||||
else
|
||||
values+="${name}"
|
||||
fi
|
||||
done
|
||||
(( $#values )) && {
|
||||
compset -P '*,'
|
||||
compset -S ',*'
|
||||
_describe "$state_descr" values -r ',=: \t\n\-' && rc=0
|
||||
}
|
||||
;;
|
||||
|
||||
files)
|
||||
compset -P '*,'
|
||||
compset -S ',*'
|
||||
_files -r ',/ \t\n\-' && rc=0
|
||||
;;
|
||||
|
||||
mfiles)
|
||||
local expl
|
||||
_tags files urls
|
||||
while _tags; do
|
||||
_requested files expl 'media file' _files && rc=0
|
||||
if _requested urls; then
|
||||
while _next_label urls expl URL; do
|
||||
_urls "$expl[@]" && rc=0
|
||||
_mpv_generate_if_changed protocols
|
||||
compadd -S '' "$expl[@]" $_mpv_completion_protocols && rc=0
|
||||
done
|
||||
fi
|
||||
(( rc )) || return 0
|
||||
done
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
return rc
|
72
.config/zsh/config/completions/completions/_ninja
Normal file
72
.config/zsh/config/completions/completions/_ninja
Normal file
@ -0,0 +1,72 @@
|
||||
#compdef ninja
|
||||
# Copyright 2011 Google Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Add the following to your .zshrc to tab-complete ninja targets
|
||||
# fpath=(path/to/ninja/misc/zsh-completion $fpath)
|
||||
|
||||
__get_targets() {
|
||||
dir="."
|
||||
if [ -n "${opt_args[-C]}" ];
|
||||
then
|
||||
eval dir="${opt_args[-C]}"
|
||||
fi
|
||||
file="build.ninja"
|
||||
if [ -n "${opt_args[-f]}" ];
|
||||
then
|
||||
eval file="${opt_args[-f]}"
|
||||
fi
|
||||
targets_command="ninja -f \"${file}\" -C \"${dir}\" -t targets all"
|
||||
eval ${targets_command} 2>/dev/null | cut -d: -f1
|
||||
}
|
||||
|
||||
__get_tools() {
|
||||
ninja -t list 2>/dev/null | while read -r a b; do echo $a; done | tail -n +2
|
||||
}
|
||||
|
||||
__get_modes() {
|
||||
ninja -d list 2>/dev/null | while read -r a b; do echo $a; done | tail -n +2 | sed '$d'
|
||||
}
|
||||
|
||||
__modes() {
|
||||
local -a modes
|
||||
modes=(${(fo)"$(__get_modes)"})
|
||||
_describe 'modes' modes
|
||||
}
|
||||
|
||||
__tools() {
|
||||
local -a tools
|
||||
tools=(${(fo)"$(__get_tools)"})
|
||||
_describe 'tools' tools
|
||||
}
|
||||
|
||||
__targets() {
|
||||
local -a targets
|
||||
targets=(${(fo)"$(__get_targets)"})
|
||||
_describe 'targets' targets
|
||||
}
|
||||
|
||||
_arguments \
|
||||
{-h,--help}'[Show help]' \
|
||||
'--version[Print ninja version]' \
|
||||
'-C+[Change to directory before doing anything else]:directories:_directories' \
|
||||
'-f+[Specify input build file (default=build.ninja)]:files:_files' \
|
||||
'-j+[Run N jobs in parallel (default=number of CPUs available)]:number of jobs' \
|
||||
'-l+[Do not start new jobs if the load average is greater than N]:number of jobs' \
|
||||
'-k+[Keep going until N jobs fail (default=1)]:number of jobs' \
|
||||
'-n[Dry run (do not run commands but act like they succeeded)]' \
|
||||
'-v[Show all command lines while building]' \
|
||||
'-d+[Enable debugging (use -d list to list modes)]:modes:__modes' \
|
||||
'-t+[Run a subtool (use -t list to list subtools)]:tools:__tools' \
|
||||
'*::targets:__targets'
|
4
.config/zsh/config/completions/completions/_nvim-env
Normal file
4
.config/zsh/config/completions/completions/_nvim-env
Normal file
@ -0,0 +1,4 @@
|
||||
#compdef nvim-env
|
||||
|
||||
local file_name_comp='*: :_files -W ${NVIM_ENVS_DIR} -g "*.norg(:r)" -S " "'
|
||||
_arguments "${file_name_comp}"
|
1687
.config/zsh/config/completions/completions/_openssl
Normal file
1687
.config/zsh/config/completions/completions/_openssl
Normal file
File diff suppressed because it is too large
Load Diff
521
.config/zsh/config/completions/completions/_pgsql_utils
Normal file
521
.config/zsh/config/completions/completions/_pgsql_utils
Normal file
@ -0,0 +1,521 @@
|
||||
#compdef psql pg_dump pg_dumpall pg_restore createdb dropdb vacuumdb createuser dropuser initdb
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users, Dominic Mitchell, Johann 'Myrkraverk' Oskarsson, Daniel Serodio, J Smith
|
||||
# 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 PostgreSQL utils (http://postgresql.org).
|
||||
#
|
||||
# Source: http://www.zsh.org/mla/users/2004/msg01006.html
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Dominic Mitchell <dom+zsh@happygiraffe.net>
|
||||
#
|
||||
# * Johann 'Myrkraverk' Oskarsson <johann@2ndquadrant.com>
|
||||
#
|
||||
# * Daniel Serodio <dserodio@gmail.com> pg_dumpall completion
|
||||
#
|
||||
# * J Smith <dark.panda@gmail.com> various completion additions
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
_pgsql_get_identity () {
|
||||
_pgsql_user=${(v)opt_args[(i)-U|--username]}
|
||||
_pgsql_port=${(v)opt_args[(i)-p|--port]}
|
||||
_pgsql_host=${(v)opt_args[(i)-h|--host]}
|
||||
|
||||
_pgsql_params=(
|
||||
${_pgsql_user:+"--username=$_pgsql_user"}
|
||||
${_pgsql_port:+"--port=$_pgsql_port"}
|
||||
${_pgsql_host:+"--host=$_pgsql_host"}
|
||||
)
|
||||
}
|
||||
|
||||
# Postgres Allows specifying the path to the directory containing the
|
||||
# socket as well as a hostname.
|
||||
_pgsql_host_or_dir() {
|
||||
_alternative \
|
||||
'hosts:host:_hosts' \
|
||||
'directories:directory:_directories'
|
||||
}
|
||||
|
||||
# This creates a port completion list based on socket files on the
|
||||
# local computer. Be default, Postgres puts them in /tmp/ but Debian
|
||||
# changed that to /var/run/postgresql/ in their packages.
|
||||
_pgsql_ports() {
|
||||
compadd "$@" - /tmp/.s.PGSQL.<->(N:e) /var/run/postgresql/.s.PGSQL.<->(N:e)
|
||||
}
|
||||
|
||||
_pgsql_users () {
|
||||
local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
|
||||
local _pgsql_user_sql
|
||||
_pgsql_get_identity
|
||||
|
||||
# We use _pgsql_port and _pgsql_host directly here instead of
|
||||
# _pgsql_params so as to not pick up a partially completed
|
||||
# username.
|
||||
_pgsql_params=(
|
||||
${_pgsql_port:+"--port=$_pgsql_port"}
|
||||
${_pgsql_host:+"--host=$_pgsql_host"}
|
||||
)
|
||||
|
||||
_pgsql_user_sql='select r.rolname from pg_catalog.pg_roles r where r.rolcanlogin = true'
|
||||
|
||||
compadd "$@" - $( psql $_pgsql_params[@] -XAqt -c $_pgsql_user_sql template1 2>/dev/null )
|
||||
|
||||
}
|
||||
|
||||
_pgsql_tables () {
|
||||
local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
|
||||
_pgsql_get_identity
|
||||
|
||||
# Need to pull out the database name from the existing arguments.
|
||||
# This is going to vary between commands. Thankfully, it's only
|
||||
# used by pg_dump, which always has the dbname in arg1. If it's
|
||||
# not present it defaults to ${PGDATABASE:-$LOGNAME}, which
|
||||
# matches (I think) the PostgreSQL behaviour.
|
||||
|
||||
local db
|
||||
db=${line[1]:-${PGDATABASE:-$LOGNAME}}
|
||||
|
||||
## Instead of parsing the output of the psql \ commands, we look
|
||||
## up the tables ourselves. The following query has been tested
|
||||
## with Postgres 8.2 - 9.2.
|
||||
|
||||
local _pgsql_table_sql
|
||||
_pgsql_table_sql="select n.nspname || '.' || c.relname \
|
||||
from pg_catalog.pg_class c \
|
||||
left join pg_catalog.pg_namespace n on n.oid = c.relnamespace \
|
||||
where c.relkind in ('r', '') \
|
||||
and n.nspname <> 'pg_catalog' \
|
||||
and n.nspname <> 'information_schema' \
|
||||
and n.nspname !~ '^pg_toast' \
|
||||
and pg_catalog.pg_table_is_visible( c.oid ) \
|
||||
order by 1"
|
||||
|
||||
compadd "$@" - \
|
||||
$( psql $_pgsql_params[@] -AXqt -c $_pgsql_table_sql $db 2>/dev/null )
|
||||
}
|
||||
|
||||
_pgsql_schemas () {
|
||||
local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
|
||||
_pgsql_get_identity
|
||||
|
||||
local db
|
||||
db=${line[1]:-${PGDATABASE:-$LOGNAME}}
|
||||
|
||||
local _pgsql_schema_sql="select n.nspname \
|
||||
from pg_catalog.pg_namespace n \
|
||||
where n.nspname !~ '^pg_' \
|
||||
and n.nspname <> 'information_schema' \
|
||||
order by 1;"
|
||||
|
||||
compadd "$@" - \
|
||||
$( psql $_pgsql_params[@] -AXqt -c $_pgsql_schema_sql $db 2>/dev/null )
|
||||
}
|
||||
|
||||
_pgsql_databases () {
|
||||
local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
|
||||
_pgsql_get_identity
|
||||
|
||||
local _pgsql_services _pgsql_service_files
|
||||
_pgsql_service_files=(~/.pg_service.conf)
|
||||
(( $+commands[pg_config] )) && _pgsql_service_files+=$(pg_config --sysconfdir)/pg_service.conf
|
||||
|
||||
_pgsql_services=$( grep -h '^\[.*\]' $_pgsql_service_files 2>/dev/null \
|
||||
| sed -e 's/^\[/service=/' -e 's/\].*$//' )
|
||||
|
||||
local _pgsql_db_sql
|
||||
_pgsql_db_sql="select d.datname from pg_catalog.pg_database d \
|
||||
where d.datname <> 'template0'"
|
||||
|
||||
compadd "$@" - \
|
||||
${(f)_pgsql_services} \
|
||||
$( psql $_pgsql_params[@] -AXtq -c $_pgsql_db_sql template1 2>/dev/null )
|
||||
}
|
||||
|
||||
_pgsql_encodings () {
|
||||
local _pgsql_user
|
||||
_pgsql_get_identity
|
||||
|
||||
local _pgsql_db_sql
|
||||
_pgsql_db_sql="select pg_encoding_to_char(i) from generate_series(0,100) i;"
|
||||
|
||||
compadd "$@" - $( psql $_pgsql_params[@] -AXtq -c $_pgsql_db_sql template1 )
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
## The actual completion code for the commands
|
||||
##
|
||||
|
||||
_psql () {
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s "-*" \
|
||||
"$_pgsql_common_opts[@]" \
|
||||
{-V,--version}'[display client version]' \
|
||||
{-a,--echo-all}'[print commands read]' \
|
||||
{-A,--no-align}'[unaligned output mode]' \
|
||||
{-c+,--command=}':execute SQL command:' \
|
||||
{-d+,--dbname=}':database to connect to:_pgsql_databases' \
|
||||
{-b,--echo-errors}'[echo failed commands]' \
|
||||
{-e,--echo-queries}'[display queries submitted]' \
|
||||
{-E,--echo-hidden}'[display hidden queries]' \
|
||||
{-L,--log-file=}'[send session log to file]' \
|
||||
{-n,--no-readline}'[disable enhanced command line editing (readline)]' \
|
||||
{-f+,--file=}':SQL file to read:_files' \
|
||||
{-F+,--field-separator=}':field separator char:' \
|
||||
{-H,--html}'[HTML output]' \
|
||||
{-l,--list}'[list databases]' \
|
||||
{-o+,--output=}':query output:_files' \
|
||||
{-P+,--pset=}':set psql variable:' \
|
||||
{-q,--quiet}'[non verbose mode]' \
|
||||
{-R+,--record-separator=}':record separator char:' \
|
||||
{-s,--single-step}'[prompt before each query]' \
|
||||
{-S,--single-line}'[newline sends query]' \
|
||||
{-t,--tuples-only}'[don'\''t display header/footer]' \
|
||||
{-T+,--table-attr=}':HTML table options:' \
|
||||
-u'[prompt for username/password]' \
|
||||
{-v+,--set=,--variable=}':set SQL variable:' \
|
||||
{-x,--expanded}'[one column per line]' \
|
||||
{-z,--field-separator-zero}'[set field separator for unaligned output to zero byte]' \
|
||||
{-0,--record-separator-zero}'[set record separator for unaligned output to zero byte]' \
|
||||
{-X,--no-psqlrc}'[don'\''t read ~/.psqlrc]' \
|
||||
':PostgreSQL database:_pgsql_databases' \
|
||||
':PostgreSQL user:_pgsql_users'
|
||||
}
|
||||
|
||||
_pg_dump () {
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s \
|
||||
"$_pgsql_common_opts[@]" \
|
||||
{-a,--data-only}'[dump only data]' \
|
||||
{-b,--blobs}'[dump blobs as well]' \
|
||||
{-c,--clean}'[include clean cmds in dump]' \
|
||||
{-C,--create}'[include createdb cmds in dump]' \
|
||||
{-E+,--encoding=}':database encoding:_pgsql_encodings' \
|
||||
{-d,--inserts}'[use INSERT not COPY]' \
|
||||
{-D,--{attribute,column}-inserts}'[use INSERT (cols) not COPY]' \
|
||||
{-f+,--file=}':output file:_files' \
|
||||
{-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \
|
||||
{-j,--jobs=}'[use this many parallel jobs to dump]' \
|
||||
{-i,--ignore-version}'[ignore version mismatch]' \
|
||||
{-n+,--schema=}':schema to dump:_pgsql_schemas' \
|
||||
{-N+,--exclude-schema=}':schema to NOT dump:_pgsql_schemas' \
|
||||
{-o,--oids}'[dump objects identifiers for every table]' \
|
||||
{-O,--no-owner}'[don'\''t recreate as same owner]' \
|
||||
{-R,--no-reconnect}'[don'\''t output connect]' \
|
||||
{-s,--schema-only}'[no data, only schema]' \
|
||||
{-S+,--superuser=}':superuser name:_pgsql_users' \
|
||||
{-t+,--table=}':table to dump:_pgsql_tables' \
|
||||
{-T+,--exclude-table=}':table to NOT dump:_pgsql_tables' \
|
||||
{-v,--verbose}'[verbose mode]' \
|
||||
{-V,--version}'[display client version]' \
|
||||
{-x,--no-{acl,privileges}}'[don'\''t dump ACLs]' \
|
||||
-X+':option:_values "option" use-set-session-authorization disable-triggers' \
|
||||
{-Z+,--compress=}':compression level:_values "level" 9 8 7 6 5 4 3 2 1 0' \
|
||||
':PostgreSQL database:_pgsql_databases' \
|
||||
--section=':dump named section:_values "section" pre-data data post-data' \
|
||||
--binary-upgrade'[for use by upgrade utilities only]' \
|
||||
--column-inserts'[dump data as INSERT commands with column names]' \
|
||||
--disable-dollar-quoting'[disable dollar quoting, use SQL standard quoting]' \
|
||||
--disable-triggers'[disable triggers during data-only restore]' \
|
||||
--enable-row-security'[enable row security (dump only content user has access to)]' \
|
||||
--exclude-table-data='[do NOT dump data for the named table(s)]' \
|
||||
--if-exists'[use IF EXISTS when dropping objects]' \
|
||||
--inserts'[dump data as INSERT commands, rather than COPY]' \
|
||||
--lock-wait-timeout='[fail after waiting TIMEOUT for a table lock]' \
|
||||
--load-via-partition-root'[load partitions via the root table]' \
|
||||
--no-comments'[do not dump comments]' \
|
||||
--no-publications'[do not dump publications]' \
|
||||
--no-security-labels'[do not dump security label assignments]' \
|
||||
--no-synchronized-snapshots'[do not use synchronized snapshots in parallel jobs]' \
|
||||
--no-tablespaces'[do not dump tablespace assignments]' \
|
||||
--no-unlogged-table-data'[do not dump unlogged table data]' \
|
||||
--on-conflict-do-nothing'[add ON CONFLICT DO NOTHING to INSERT commands]' \
|
||||
--quote-all-identifiers'[quote all identifiers, even if not key words]' \
|
||||
--serializable-deferrable'[wait until the dump can run without anomalies]' \
|
||||
--snapshot='[use given snapshot for the dump]' \
|
||||
--strict-names'[require table and/or schema include patterns to match at least one entity each]' \
|
||||
--use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER]'
|
||||
}
|
||||
|
||||
_pg_restore () {
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s \
|
||||
"$_pgsql_common_opts[@]" \
|
||||
{-d+,--dbname=}':database to connect to:_pgsql_databases' \
|
||||
{-f+,--file=}':output file:_files' \
|
||||
{-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \
|
||||
{-l,--list}'[list databases]' \
|
||||
{-a,--data-only}'[dump only data]' \
|
||||
{-b,--blobs}'[include large objects in dump]' \
|
||||
{-B,--no-blobs}'[exclude large objects in dump]' \
|
||||
{-c,--clean}'[include clean (drop) cmds before recreating]' \
|
||||
{-C,--create}'[include createdb cmds in dump]' \
|
||||
{-e,--exit-on-error}'[exit on error, default is to continue]' \
|
||||
{-I,--index=}':index name:' \
|
||||
{-j,--jobs=}':use this many parallel jobs to restore:' \
|
||||
{-L,--use-list=}':use table of contents from this file for selecting/ordering output:' \
|
||||
{-n,--schema=}':restore only objects in this schema:' \
|
||||
{-O,--no-owner}'[skip restoration of object ownership]' \
|
||||
{-P,--function=}':restore named function:' \
|
||||
{-s,--schema-only}'[restore only the schema, no data]' \
|
||||
{-S,--superuser=}':superuser user name to use for disabling triggers:' \
|
||||
{-t,--table=}':restore named table:' \
|
||||
{-T,--trigger=}':restore named trigger:' \
|
||||
{-x,--no-privileges}'[skip restoration of access privileges (grant/revoke)]' \
|
||||
{-1,--single-transaction}'[restore as a single transaction]' \
|
||||
{-v,--verbose}'[verbose mode]' \
|
||||
{-V,--version}'[display client version]' \
|
||||
--disable-triggers'[disable triggers during data-only restore]' \
|
||||
--enable-row-security'[enable row security]' \
|
||||
--if-exists'[use IF EXISTS when dropping objects]' \
|
||||
--no-comments'[do not restore comments]' \
|
||||
--no-data-for-failed-tables'[do not restore data of tables that could not be created]' \
|
||||
--no-publications'[do not restore publications]' \
|
||||
--no-security-labels'[do not restore security labels]' \
|
||||
--no-subscriptions'[do not restore subscriptions]' \
|
||||
--no-tablespaces'[do not restore tablespace assignments]' \
|
||||
--section=':dump named section:_values "section" pre-data data post-data' \
|
||||
--use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to set ownership]' \
|
||||
"1: :_files"
|
||||
}
|
||||
|
||||
_pg_dumpall () {
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s \
|
||||
"$_pgsql_common_opts[@]" \
|
||||
{-a,--data-only}'[dump only data]' \
|
||||
{-c,--clean}'[include clean (drop) cmds before recreating]' \
|
||||
{-g,--globals-only}'[dump only global objects, no databases]' \
|
||||
{-f+,--file=}':output file:_files' \
|
||||
{-o,--oids}'[dump objects identifiers for every table]' \
|
||||
{-O,--no-owner}'[don'\''t recreate as same owner]' \
|
||||
{-r,--roles-only}'[no databases or tablespaces, only roles]' \
|
||||
{-s,--schema-only}'[no data, only schema]' \
|
||||
{-S+,--superuser=}':superuser name:_pgsql_users' \
|
||||
{-t,--tablespaces-only}'[no databases or roles, only tablespaces]' \
|
||||
{-x,--no-privileges}'[don'\''t dump ACLs]' \
|
||||
--binary-upgrade'[for use by upgrade utilities only]' \
|
||||
--column-inserts'[use INSERT with column names not COPY]' \
|
||||
--disable-dollar-quoting'[disable dollar quoting, use SQL standard quoting]' \
|
||||
--disable-triggers'[disable triggers during data-only restore]' \
|
||||
--inserts'[use INSERT not COPY]' \
|
||||
--no-security-labels'[do not dump security label assignments]' \
|
||||
--no-tablespaces'[do not dump tablespace assignments]' \
|
||||
--no-unlogged-table-data'[do not dump unlogged table data]' \
|
||||
--quote-all-identifiers'[quote all identifiers, even if not key words]' \
|
||||
--use-set-session-authorization'[use SET SESSION AUTHORIZATION cmds instead of ALTER OWNER]'
|
||||
}
|
||||
|
||||
_createdb () {
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s \
|
||||
"$_pgsql_common_opts[@]" \
|
||||
{-e,--echo}'[display SQL queries]' \
|
||||
{-q,--quiet}'[non verbose mode]' \
|
||||
{-D+,--location=}':database location:_directories' \
|
||||
{-T+,--template=}':database template:_pgsql_databases' \
|
||||
{-E+,--encoding=}':database encoding:_pgsql_encodings' \
|
||||
':PostgreSQL database:' \
|
||||
':comment:'
|
||||
}
|
||||
|
||||
_dropdb () {
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s \
|
||||
"$_pgsql_common_opts[@]" \
|
||||
{-e,--echo}'[display SQL queries]' \
|
||||
{-q,--quiet}'[non verbose mode]' \
|
||||
{-i,--interactive}'[confirm before drop]' \
|
||||
':PostgreSQL database:_pgsql_databases'
|
||||
}
|
||||
|
||||
_vacuumdb () {
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s \
|
||||
"$_pgsql_common_opts[@]" \
|
||||
{-a,--all}'[vacuum all databases]' \
|
||||
{-d+,--dbname=}':database to connect to:_pgsql_databases' \
|
||||
{-t+,--table=}':table to dump:_pgsql_tables' \
|
||||
{-f,--full}'[do full vacuuming]' \
|
||||
{-z,--analyze}'[update optimizer hints]' \
|
||||
{-Z,--analyze-only}'[only update optimizer statistics; no vacuum]' \
|
||||
{-e,--echo}'[show the commands being sent to the server]' \
|
||||
{-q,--quiet}'[do not write any messages]' \
|
||||
{-v,--verbose}'[write a lot of output]' \
|
||||
'--min-mxid-age=[minimum multixact ID age of tables to vacuum]' \
|
||||
'--min-xid-age=[minimum transaction ID age of tables to vacuum]' \
|
||||
'--skip-locked[skip relations that cannot be immediately locked]' \
|
||||
'--analyze-in-stages[only update optimizer statistics, in multiple]' \
|
||||
'--help[show this help, then exit]' \
|
||||
'--version[output version information, then exit]' \
|
||||
'--maintenance-db=[alternate maintenance database]' \
|
||||
'1:PostgreSQL database:_pgsql_databases'
|
||||
}
|
||||
|
||||
_createuser () {
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s \
|
||||
"$_pgsql_common_opts[@]" \
|
||||
{-e,--echo}'[display SQL queries]' \
|
||||
{-c,--connection-limit=}'[connection limit for role (default: no limit)]' \
|
||||
{-d,--createdb}'[role can create new databases]' \
|
||||
{-D,--no-createdb}'[role cannot create databases]' \
|
||||
{-E,--encrypted}'[encrypt stored password]' \
|
||||
{-g,--role=}'[new role will be a member of this role]' \
|
||||
{-i,--inherit}'[role inherits privileges of roles it is a member of (default)]' \
|
||||
{-I,--no-inherit}'[role does not inherit privileges]' \
|
||||
{-l,--login}'[role can login (default)]' \
|
||||
{-L,--no-login}'[role cannot login]' \
|
||||
{-N,--unencrypted}'[do not encrypt stored password]' \
|
||||
{-P,--pwprompt}'[assign a password to new role]' \
|
||||
{-r,--createrole}'[role can create new roles]' \
|
||||
{-R,--no-createrole}'[role cannot create roles]' \
|
||||
{-s,--superuser}'[role will be superuser]' \
|
||||
{-S,--no-superuser}'[role will not be superuser]' \
|
||||
--interactive'[prompt for missing role name and attributes rather than using defaults]' \
|
||||
--replication'[role can initiate replication]' \
|
||||
--no-replication'[role cannot initiate replication]' \
|
||||
}
|
||||
|
||||
_dropuser () {
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s \
|
||||
"$_pgsql_common_opts[@]" \
|
||||
{-e,--echo}'[display SQL queries]' \
|
||||
{-q,--quiet}'[non verbose mode]' \
|
||||
{-i,--interactive}'[prompt before deleting anything, and prompt for role name if not specified]' \
|
||||
':PostgreSQL user:_pgsql_users'
|
||||
}
|
||||
|
||||
_initdb () {
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s \
|
||||
{--auth=,-A+}':default authentication method for local connections:_values "auth methods" $_pgsql_auth_methods[@]' \
|
||||
--auth-host=':default authentication method for local TCP/IP connections:_values "auth methods" $_pgsql_auth_methods[@]' \
|
||||
--auth-local=':default authentication method for local-socket connections:_values "auth methods" $_pgsql_auth_methods[@]' \
|
||||
{-D+,--pgdata=}':location for this database cluster:_files' \
|
||||
{-E+,--encoding=}':set default encoding for new databases:' \
|
||||
--locale=':set default locale for new databases:' \
|
||||
--lc-collate=':set the default locale for collate:' \
|
||||
--lc-ctype=':set the default locale for ctype:' \
|
||||
--lc-messages=':set the default locale for messages:' \
|
||||
--lc-monetary=':set the default locale for monetary:' \
|
||||
--lc-numeric=':set the default locale for numeric:' \
|
||||
--lc-time=':set the default local for time:' \
|
||||
--no-locale'[equivalent to --locale=C]' \
|
||||
--pwfile=':read password for the new superuser from file:_files' \
|
||||
{-T+,--text-search-config=}'[default text search configuration]' \
|
||||
{-U+,--username=NAME}':database superuser name:' \
|
||||
{-W,--pwprompt}'[prompt for a password for the new superuser]' \
|
||||
{-X+,--xlogdir=}':location for the transaction log directory:_files' \
|
||||
{-d,--debug}'[generate lots of debugging output]' \
|
||||
-L+':where to find the input files:_files' \
|
||||
{-k,--data-checksums}':use data page checksums:' \
|
||||
{-n,--noclean}'[do not clean up after errors]' \
|
||||
{-N,--nosync}':do not wait for changes to be written safely to disk:' \
|
||||
{-s,--show}'[show internal settings]' \
|
||||
{-S,--sync-only}'[only sync data directory]' \
|
||||
':location for this database cluster:_files'
|
||||
}
|
||||
|
||||
_pgsql_utils () {
|
||||
local _pgsql_common_opts _pgsql_auth_methods
|
||||
|
||||
_pgsql_common_opts=(
|
||||
{-\?,--help}'[display help]'
|
||||
{-h+,--host=}':database host:_pgsql_host_or_dir'
|
||||
{-p+,--port=}':database port number:_pgsql_ports'
|
||||
{-U+,--username=}':connect as user:_pgsql_users'
|
||||
{-W,--password}'[prompt for password]'
|
||||
--role='[do SET ROLE before restore]'
|
||||
)
|
||||
|
||||
_pgsql_auth_methods=(
|
||||
trust
|
||||
reject
|
||||
md5
|
||||
password
|
||||
gss
|
||||
sspi
|
||||
krb5
|
||||
ident
|
||||
peer
|
||||
ldap
|
||||
radius
|
||||
cert
|
||||
pam
|
||||
)
|
||||
|
||||
case "$service" in
|
||||
psql) _psql "$@" ;;
|
||||
pg_dump) _pg_dump "$@" ;;
|
||||
pg_restore) _pg_restore "$@" ;;
|
||||
createdb) _createdb "$@" ;;
|
||||
dropdb) _dropdb "$@" ;;
|
||||
vacuumdb) _vacuumdb "$@" ;;
|
||||
createuser) _createuser "$@" ;;
|
||||
dropuser) _dropuser "$@" ;;
|
||||
initdb) _initdb "$@" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_pgsql_utils "$@"
|
||||
|
||||
# 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
|
640
.config/zsh/config/completions/completions/_rg
Normal file
640
.config/zsh/config/completions/completions/_rg
Normal file
@ -0,0 +1,640 @@
|
||||
#compdef rg
|
||||
|
||||
##
|
||||
# zsh completion function for ripgrep
|
||||
#
|
||||
# Run ci/test-complete after building to ensure that the options supported by
|
||||
# this function stay in synch with the `rg` binary.
|
||||
#
|
||||
# For convenience, a completion reference guide is included at the bottom of
|
||||
# this file.
|
||||
#
|
||||
# Originally based on code from the zsh-users project — see copyright notice
|
||||
# below.
|
||||
|
||||
_rg() {
|
||||
local curcontext=$curcontext no='!' descr ret=1
|
||||
local -a context line state state_descr args tmp suf
|
||||
local -A opt_args
|
||||
|
||||
# ripgrep has many options which negate the effect of a more common one — for
|
||||
# example, `--no-column` to negate `--column`, and `--messages` to negate
|
||||
# `--no-messages`. There are so many of these, and they're so infrequently
|
||||
# used, that some users will probably find it irritating if they're completed
|
||||
# indiscriminately, so let's not do that unless either the current prefix
|
||||
# matches one of those negation options or the user has the `complete-all`
|
||||
# style set. Note that this prefix check has to be updated manually to account
|
||||
# for all of the potential negation options listed below!
|
||||
if
|
||||
# We also want to list all of these options during testing
|
||||
[[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] ||
|
||||
# (--[imnp]* => --ignore*, --messages, --no-*, --pcre2-unicode)
|
||||
[[ $PREFIX$SUFFIX == --[imnp]* ]] ||
|
||||
zstyle -t ":complete:$curcontext:*" complete-all
|
||||
then
|
||||
no=
|
||||
fi
|
||||
|
||||
# We make heavy use of argument groups here to prevent the option specs from
|
||||
# growing unwieldy. These aren't supported in zsh <5.4, though, so we'll strip
|
||||
# them out below if necessary. This makes the exclusions inaccurate on those
|
||||
# older versions, but oh well — it's not that big a deal
|
||||
args=(
|
||||
+ '(exclusive)' # Misc. fully exclusive options
|
||||
'(: * -)'{-h,--help}'[display help information]'
|
||||
'(: * -)'{-V,--version}'[display version information]'
|
||||
'(: * -)'--pcre2-version'[print the version of PCRE2 used by ripgrep, if available]'
|
||||
|
||||
+ '(buffered)' # buffering options
|
||||
'--line-buffered[force line buffering]'
|
||||
$no"--no-line-buffered[don't force line buffering]"
|
||||
'--block-buffered[force block buffering]'
|
||||
$no"--no-block-buffered[don't force block buffering]"
|
||||
|
||||
+ '(case)' # Case-sensitivity options
|
||||
{-i,--ignore-case}'[search case-insensitively]'
|
||||
{-s,--case-sensitive}'[search case-sensitively]'
|
||||
{-S,--smart-case}'[search case-insensitively if pattern is all lowercase]'
|
||||
|
||||
+ '(context-a)' # Context (after) options
|
||||
'(context-c)'{-A+,--after-context=}'[specify lines to show after each match]:number of lines'
|
||||
|
||||
+ '(context-b)' # Context (before) options
|
||||
'(context-c)'{-B+,--before-context=}'[specify lines to show before each match]:number of lines'
|
||||
|
||||
+ '(context-c)' # Context (combined) options
|
||||
'(context-a context-b)'{-C+,--context=}'[specify lines to show before and after each match]:number of lines'
|
||||
|
||||
+ '(column)' # Column options
|
||||
'--column[show column numbers for matches]'
|
||||
$no"--no-column[don't show column numbers for matches]"
|
||||
|
||||
+ '(count)' # Counting options
|
||||
{-c,--count}'[only show count of matching lines for each file]'
|
||||
'--count-matches[only show count of individual matches for each file]'
|
||||
'--include-zero[include files with zero matches in summary]'
|
||||
|
||||
+ '(encoding)' # Encoding options
|
||||
{-E+,--encoding=}'[specify text encoding of files to search]: :_rg_encodings'
|
||||
$no'--no-encoding[use default text encoding]'
|
||||
|
||||
+ '(engine)' # Engine choice options
|
||||
'--engine=[select which regex engine to use]:when:((
|
||||
default\:"use default engine"
|
||||
pcre2\:"identical to --pcre2"
|
||||
auto\:"identical to --auto-hybrid-regex"
|
||||
))'
|
||||
|
||||
+ file # File-input options
|
||||
'(1)*'{-f+,--file=}'[specify file containing patterns to search for]: :_files'
|
||||
|
||||
+ '(file-match)' # Files with/without match options
|
||||
'(stats)'{-l,--files-with-matches}'[only show names of files with matches]'
|
||||
'(stats)--files-without-match[only show names of files without matches]'
|
||||
|
||||
+ '(file-name)' # File-name options
|
||||
{-H,--with-filename}'[show file name for matches]'
|
||||
{-I,--no-filename}"[don't show file name for matches]"
|
||||
|
||||
+ '(file-system)' # File system options
|
||||
"--one-file-system[don't descend into directories on other file systems]"
|
||||
$no'--no-one-file-system[descend into directories on other file systems]'
|
||||
|
||||
+ '(fixed)' # Fixed-string options
|
||||
{-F,--fixed-strings}'[treat pattern as literal string instead of regular expression]'
|
||||
$no"--no-fixed-strings[don't treat pattern as literal string]"
|
||||
|
||||
+ '(follow)' # Symlink-following options
|
||||
{-L,--follow}'[follow symlinks]'
|
||||
$no"--no-follow[don't follow symlinks]"
|
||||
|
||||
+ glob # File-glob options
|
||||
'*'{-g+,--glob=}'[include/exclude files matching specified glob]:glob'
|
||||
'*--iglob=[include/exclude files matching specified case-insensitive glob]:glob'
|
||||
|
||||
+ '(glob-case-insensitive)' # File-glob case sensitivity options
|
||||
'--glob-case-insensitive[treat -g/--glob patterns case insensitively]'
|
||||
$no'--no-glob-case-insensitive[treat -g/--glob patterns case sensitively]'
|
||||
|
||||
+ '(heading)' # Heading options
|
||||
'(pretty-vimgrep)--heading[show matches grouped by file name]'
|
||||
"(pretty-vimgrep)--no-heading[don't show matches grouped by file name]"
|
||||
|
||||
+ '(hidden)' # Hidden-file options
|
||||
{-.,--hidden}'[search hidden files and directories]'
|
||||
$no"--no-hidden[don't search hidden files and directories]"
|
||||
|
||||
+ '(hybrid)' # hybrid regex options
|
||||
'--auto-hybrid-regex[dynamically use PCRE2 if necessary]'
|
||||
$no"--no-auto-hybrid-regex[don't dynamically use PCRE2 if necessary]"
|
||||
|
||||
+ '(ignore)' # Ignore-file options
|
||||
"(--no-ignore-global --no-ignore-parent --no-ignore-vcs --no-ignore-dot)--no-ignore[don't respect ignore files]"
|
||||
$no'(--ignore-global --ignore-parent --ignore-vcs --ignore-dot)--ignore[respect ignore files]'
|
||||
|
||||
+ '(ignore-file-case-insensitive)' # Ignore-file case sensitivity options
|
||||
'--ignore-file-case-insensitive[process ignore files case insensitively]'
|
||||
$no'--no-ignore-file-case-insensitive[process ignore files case sensitively]'
|
||||
|
||||
+ '(ignore-exclude)' # Local exclude (ignore)-file options
|
||||
"--no-ignore-exclude[don't respect local exclude (ignore) files]"
|
||||
$no'--ignore-exclude[respect local exclude (ignore) files]'
|
||||
|
||||
+ '(ignore-global)' # Global ignore-file options
|
||||
"--no-ignore-global[don't respect global ignore files]"
|
||||
$no'--ignore-global[respect global ignore files]'
|
||||
|
||||
+ '(ignore-parent)' # Parent ignore-file options
|
||||
"--no-ignore-parent[don't respect ignore files in parent directories]"
|
||||
$no'--ignore-parent[respect ignore files in parent directories]'
|
||||
|
||||
+ '(ignore-vcs)' # VCS ignore-file options
|
||||
"--no-ignore-vcs[don't respect version control ignore files]"
|
||||
$no'--ignore-vcs[respect version control ignore files]'
|
||||
|
||||
+ '(require-git)' # git specific settings
|
||||
"--no-require-git[don't require git repository to respect gitignore rules]"
|
||||
$no'--require-git[require git repository to respect gitignore rules]'
|
||||
|
||||
+ '(ignore-dot)' # .ignore options
|
||||
"--no-ignore-dot[don't respect .ignore files]"
|
||||
$no'--ignore-dot[respect .ignore files]'
|
||||
|
||||
+ '(ignore-files)' # custom global ignore file options
|
||||
"--no-ignore-files[don't respect --ignore-file flags]"
|
||||
$no'--ignore-files[respect --ignore-file files]'
|
||||
|
||||
+ '(json)' # JSON options
|
||||
'--json[output results in JSON Lines format]'
|
||||
$no"--no-json[don't output results in JSON Lines format]"
|
||||
|
||||
+ '(line-number)' # Line-number options
|
||||
{-n,--line-number}'[show line numbers for matches]'
|
||||
{-N,--no-line-number}"[don't show line numbers for matches]"
|
||||
|
||||
+ '(line-terminator)' # Line-terminator options
|
||||
'--crlf[use CRLF as line terminator]'
|
||||
$no"--no-crlf[don't use CRLF as line terminator]"
|
||||
'(text)--null-data[use NUL as line terminator]'
|
||||
|
||||
+ '(max-columns-preview)' # max column preview options
|
||||
'--max-columns-preview[show preview for long lines (with -M)]'
|
||||
$no"--no-max-columns-preview[don't show preview for long lines (with -M)]"
|
||||
|
||||
+ '(max-depth)' # Directory-depth options
|
||||
'--max-depth=[specify max number of directories to descend]:number of directories'
|
||||
'!--maxdepth=:number of directories'
|
||||
|
||||
+ '(messages)' # Error-message options
|
||||
'(--no-ignore-messages)--no-messages[suppress some error messages]'
|
||||
$no"--messages[don't suppress error messages affected by --no-messages]"
|
||||
|
||||
+ '(messages-ignore)' # Ignore-error message options
|
||||
"--no-ignore-messages[don't show ignore-file parse error messages]"
|
||||
$no'--ignore-messages[show ignore-file parse error messages]'
|
||||
|
||||
+ '(mmap)' # mmap options
|
||||
'--mmap[search using memory maps when possible]'
|
||||
"--no-mmap[don't search using memory maps]"
|
||||
|
||||
+ '(multiline)' # Multiline options
|
||||
{-U,--multiline}'[permit matching across multiple lines]'
|
||||
$no'(multiline-dotall)--no-multiline[restrict matches to at most one line each]'
|
||||
|
||||
+ '(multiline-dotall)' # Multiline DOTALL options
|
||||
'(--no-multiline)--multiline-dotall[allow "." to match newline (with -U)]'
|
||||
$no"(--no-multiline)--no-multiline-dotall[don't allow \".\" to match newline (with -U)]"
|
||||
|
||||
+ '(only)' # Only-match options
|
||||
{-o,--only-matching}'[show only matching part of each line]'
|
||||
|
||||
+ '(passthru)' # Pass-through options
|
||||
'(--vimgrep)--passthru[show both matching and non-matching lines]'
|
||||
'!(--vimgrep)--passthrough'
|
||||
|
||||
+ '(pcre2)' # PCRE2 options
|
||||
{-P,--pcre2}'[enable matching with PCRE2]'
|
||||
$no'(pcre2-unicode)--no-pcre2[disable matching with PCRE2]'
|
||||
|
||||
+ '(pcre2-unicode)' # PCRE2 Unicode options
|
||||
$no'(--no-pcre2 --no-pcre2-unicode)--pcre2-unicode[enable PCRE2 Unicode mode (with -P)]'
|
||||
'(--no-pcre2 --pcre2-unicode)--no-pcre2-unicode[disable PCRE2 Unicode mode (with -P)]'
|
||||
|
||||
+ '(pre)' # Preprocessing options
|
||||
'(-z --search-zip)--pre=[specify preprocessor utility]:preprocessor utility:_command_names -e'
|
||||
$no'--no-pre[disable preprocessor utility]'
|
||||
|
||||
+ pre-glob # Preprocessing glob options
|
||||
'*--pre-glob[include/exclude files for preprocessing with --pre]'
|
||||
|
||||
+ '(pretty-vimgrep)' # Pretty/vimgrep display options
|
||||
'(heading)'{-p,--pretty}'[alias for --color=always --heading -n]'
|
||||
'(heading passthru)--vimgrep[show results in vim-compatible format]'
|
||||
|
||||
+ regexp # Explicit pattern options
|
||||
'(1 file)*'{-e+,--regexp=}'[specify pattern]:pattern'
|
||||
|
||||
+ '(replace)' # Replacement options
|
||||
{-r+,--replace=}'[specify string used to replace matches]:replace string'
|
||||
|
||||
+ '(sort)' # File-sorting options
|
||||
'(threads)--sort=[sort results in ascending order (disables parallelism)]:sort method:((
|
||||
none\:"no sorting"
|
||||
path\:"sort by file path"
|
||||
modified\:"sort by last modified time"
|
||||
accessed\:"sort by last accessed time"
|
||||
created\:"sort by creation time"
|
||||
))'
|
||||
'(threads)--sortr=[sort results in descending order (disables parallelism)]:sort method:((
|
||||
none\:"no sorting"
|
||||
path\:"sort by file path"
|
||||
modified\:"sort by last modified time"
|
||||
accessed\:"sort by last accessed time"
|
||||
created\:"sort by creation time"
|
||||
))'
|
||||
'!(threads)--sort-files[sort results by file path (disables parallelism)]'
|
||||
|
||||
+ '(stats)' # Statistics options
|
||||
'(--files file-match)--stats[show search statistics]'
|
||||
$no"--no-stats[don't show search statistics]"
|
||||
|
||||
+ '(text)' # Binary-search options
|
||||
{-a,--text}'[search binary files as if they were text]'
|
||||
"--binary[search binary files, don't print binary data]"
|
||||
$no"--no-binary[don't search binary files]"
|
||||
$no"(--null-data)--no-text[don't search binary files as if they were text]"
|
||||
|
||||
+ '(threads)' # Thread-count options
|
||||
'(sort)'{-j+,--threads=}'[specify approximate number of threads to use]:number of threads'
|
||||
|
||||
+ '(trim)' # Trim options
|
||||
'--trim[trim any ASCII whitespace prefix from each line]'
|
||||
$no"--no-trim[don't trim ASCII whitespace prefix from each line]"
|
||||
|
||||
+ type # Type options
|
||||
'*'{-t+,--type=}'[only search files matching specified type]: :_rg_types'
|
||||
'*--type-add=[add new glob for specified file type]: :->typespec'
|
||||
'*--type-clear=[clear globs previously defined for specified file type]: :_rg_types'
|
||||
# This should actually be exclusive with everything but other type options
|
||||
'(: *)--type-list[show all supported file types and their associated globs]'
|
||||
'*'{-T+,--type-not=}"[don't search files matching specified file type]: :_rg_types"
|
||||
|
||||
+ '(word-line)' # Whole-word/line match options
|
||||
{-w,--word-regexp}'[only show matches surrounded by word boundaries]'
|
||||
{-x,--line-regexp}'[only show matches surrounded by line boundaries]'
|
||||
|
||||
+ '(unicode)' # Unicode options
|
||||
$no'--unicode[enable Unicode mode]'
|
||||
'--no-unicode[disable Unicode mode]'
|
||||
|
||||
+ '(zip)' # Compression options
|
||||
'(--pre)'{-z,--search-zip}'[search in compressed files]'
|
||||
$no"--no-search-zip[don't search in compressed files]"
|
||||
|
||||
+ misc # Other options — no need to separate these at the moment
|
||||
'(-b --byte-offset)'{-b,--byte-offset}'[show 0-based byte offset for each matching line]'
|
||||
'--color=[specify when to use colors in output]:when:((
|
||||
never\:"never use colors"
|
||||
auto\:"use colors or not based on stdout, TERM, etc."
|
||||
always\:"always use colors"
|
||||
ansi\:"always use ANSI colors (even on Windows)"
|
||||
))'
|
||||
'*--colors=[specify color and style settings]: :->colorspec'
|
||||
'--context-separator=[specify string used to separate non-continuous context lines in output]:separator'
|
||||
$no"--no-context-separator[don't print context separators]"
|
||||
'--debug[show debug messages]'
|
||||
'--field-context-separator[set string to delimit fields in context lines]'
|
||||
'--field-match-separator[set string to delimit fields in matching lines]'
|
||||
'--trace[show more verbose debug messages]'
|
||||
'--dfa-size-limit=[specify upper size limit of generated DFA]:DFA size (bytes)'
|
||||
"(1 stats)--files[show each file that would be searched (but don't search)]"
|
||||
'*--ignore-file=[specify additional ignore file]:ignore file:_files'
|
||||
'(-v --invert-match)'{-v,--invert-match}'[invert matching]'
|
||||
'(-M --max-columns)'{-M+,--max-columns=}'[specify max length of lines to print]:number of bytes'
|
||||
'(-m --max-count)'{-m+,--max-count=}'[specify max number of matches per file]:number of matches'
|
||||
'--max-filesize=[specify size above which files should be ignored]:file size (bytes)'
|
||||
"--no-config[don't load configuration files]"
|
||||
'(-0 --null)'{-0,--null}'[print NUL byte after file names]'
|
||||
'--path-separator=[specify path separator to use when printing file names]:separator'
|
||||
'(-q --quiet)'{-q,--quiet}'[suppress normal output]'
|
||||
'--regex-size-limit=[specify upper size limit of compiled regex]:regex size (bytes)'
|
||||
'*'{-u,--unrestricted}'[reduce level of "smart" searching]'
|
||||
|
||||
+ operand # Operands
|
||||
'(--files --type-list file regexp)1: :_guard "^-*" pattern'
|
||||
'(--type-list)*: :_files'
|
||||
)
|
||||
|
||||
# This is used with test-complete to verify that there are no options
|
||||
# listed in the help output that aren't also defined here
|
||||
[[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] && {
|
||||
print -rl - $args
|
||||
return 0
|
||||
}
|
||||
|
||||
# Strip out argument groups where unsupported (see above)
|
||||
[[ $ZSH_VERSION == (4|5.<0-3>)(.*)# ]] &&
|
||||
args=( ${(@)args:#(#i)(+|[a-z0-9][a-z0-9_-]#|\([a-z0-9][a-z0-9_-]#\))} )
|
||||
|
||||
_arguments -C -s -S : $args && ret=0
|
||||
|
||||
case $state in
|
||||
colorspec)
|
||||
if [[ ${IPREFIX#--*=}$PREFIX == [^:]# ]]; then
|
||||
suf=( -qS: )
|
||||
tmp=(
|
||||
'column:specify coloring for column numbers'
|
||||
'line:specify coloring for line numbers'
|
||||
'match:specify coloring for match text'
|
||||
'path:specify coloring for file names'
|
||||
)
|
||||
descr='color/style type'
|
||||
elif [[ ${IPREFIX#--*=}$PREFIX == (column|line|match|path):[^:]# ]]; then
|
||||
suf=( -qS: )
|
||||
tmp=(
|
||||
'none:clear color/style for type'
|
||||
'bg:specify background color'
|
||||
'fg:specify foreground color'
|
||||
'style:specify text style'
|
||||
)
|
||||
descr='color/style attribute'
|
||||
elif [[ ${IPREFIX#--*=}$PREFIX == [^:]##:(bg|fg):[^:]# ]]; then
|
||||
tmp=( black blue green red cyan magenta yellow white )
|
||||
descr='color name or r,g,b'
|
||||
elif [[ ${IPREFIX#--*=}$PREFIX == [^:]##:style:[^:]# ]]; then
|
||||
tmp=( {,no}bold {,no}intense {,no}underline )
|
||||
descr='style name'
|
||||
else
|
||||
_message -e colorspec 'no more arguments'
|
||||
fi
|
||||
|
||||
(( $#tmp )) && {
|
||||
compset -P '*:'
|
||||
_describe -t colorspec $descr tmp $suf && ret=0
|
||||
}
|
||||
;;
|
||||
|
||||
typespec)
|
||||
if compset -P '[^:]##:include:'; then
|
||||
_sequence -s , _rg_types && ret=0
|
||||
# @todo This bit in particular could be better, but it's a little
|
||||
# complex, and attempting to solve it seems to run us up against a crash
|
||||
# bug — zsh # 40362
|
||||
elif compset -P '[^:]##:'; then
|
||||
_message 'glob or include directive' && ret=1
|
||||
elif [[ ! -prefix *:* ]]; then
|
||||
_rg_types -qS : && ret=0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
# Complete encodings
|
||||
_rg_encodings() {
|
||||
local -a expl
|
||||
local -aU _encodings
|
||||
|
||||
# This is impossible to read, but these encodings rarely if ever change, so it
|
||||
# probably doesn't matter. They are derived from the list given here:
|
||||
# https://encoding.spec.whatwg.org/#concept-encoding-get
|
||||
_encodings=(
|
||||
{{,us-}ascii,arabic,chinese,cyrillic,greek{,8},hebrew,korean}
|
||||
logical visual mac {,cs}macintosh x-mac-{cyrillic,roman,ukrainian}
|
||||
866 ibm{819,866} csibm866
|
||||
big5{,-hkscs} {cn-,cs}big5 x-x-big5
|
||||
cp{819,866,125{0..8}} x-cp125{0..8}
|
||||
csiso2022{jp,kr} csiso8859{6,8}{e,i}
|
||||
csisolatin{{1..6},9} csisolatin{arabic,cyrillic,greek,hebrew}
|
||||
ecma-{114,118} asmo-708 elot_928 sun_eu_greek
|
||||
euc-{jp,kr} x-euc-jp cseuckr cseucpkdfmtjapanese
|
||||
{,x-}gbk csiso58gb231280 gb18030 {,cs}gb2312 gb_2312{,-80} hz-gb-2312
|
||||
iso-2022-{cn,cn-ext,jp,kr}
|
||||
iso8859{,-}{{1..11},13,14,15}
|
||||
iso-8859-{{1..11},{6,8}-{e,i},13,14,15,16} iso_8859-{{1..9},15}
|
||||
iso_8859-{1,2,6,7}:1987 iso_8859-{3,4,5,8}:1988 iso_8859-9:1989
|
||||
iso-ir-{58,100,101,109,110,126,127,138,144,148,149,157}
|
||||
koi{,8,8-r,8-ru,8-u,8_r} cskoi8r
|
||||
ks_c_5601-{1987,1989} ksc{,_}5691 csksc56011987
|
||||
latin{1..6} l{{1..6},9}
|
||||
shift{-,_}jis csshiftjis {,x-}sjis ms_kanji ms932
|
||||
utf{,-}8 utf-16{,be,le} unicode-1-1-utf-8
|
||||
windows-{31j,874,949,125{0..8}} dos-874 tis-620 ansi_x3.4-1968
|
||||
x-user-defined auto none
|
||||
)
|
||||
|
||||
_wanted encodings expl encoding compadd -a "$@" - _encodings
|
||||
}
|
||||
|
||||
# Complete file types
|
||||
_rg_types() {
|
||||
local -a expl
|
||||
local -aU _types
|
||||
|
||||
_types=( ${(@)${(f)"$( _call_program types rg --type-list )"}%%:*} )
|
||||
|
||||
_wanted types expl 'file type' compadd -a "$@" - _types
|
||||
}
|
||||
|
||||
_rg "$@"
|
||||
|
||||
################################################################################
|
||||
# ZSH COMPLETION REFERENCE
|
||||
#
|
||||
# For the convenience of developers who aren't especially familiar with zsh
|
||||
# completion functions, a brief reference guide follows. This is in no way
|
||||
# comprehensive; it covers just enough of the basic structure, syntax, and
|
||||
# conventions to help someone make simple changes like adding new options. For
|
||||
# more complete documentation regarding zsh completion functions, please see the
|
||||
# following:
|
||||
#
|
||||
# * http://zsh.sourceforge.net/Doc/Release/Completion-System.html
|
||||
# * https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# Most zsh completion functions are defined in terms of `_arguments`, which is a
|
||||
# shell function that takes a series of argument specifications. The specs for
|
||||
# `rg` are stored in an array, which is common for more complex functions; the
|
||||
# elements of the array are passed to `_arguments` on invocation.
|
||||
#
|
||||
# ARGUMENT-SPECIFICATION SYNTAX
|
||||
#
|
||||
# The following is a contrived example of the argument specs for a simple tool:
|
||||
#
|
||||
# '(: * -)'{-h,--help}'[display help information]'
|
||||
# '(-q -v --quiet --verbose)'{-q,--quiet}'[decrease output verbosity]'
|
||||
# '!(-q -v --quiet --verbose)--silent'
|
||||
# '(-q -v --quiet --verbose)'{-v,--verbose}'[increase output verbosity]'
|
||||
# '--color=[specify when to use colors]:when:(always never auto)'
|
||||
# '*:example file:_files'
|
||||
#
|
||||
# Although there may appear to be six specs here, there are actually nine; we
|
||||
# use brace expansion to combine specs for options that go by multiple names,
|
||||
# like `-q` and `--quiet`. This is customary, and ties in with the fact that zsh
|
||||
# merges completion possibilities together when they have the same description.
|
||||
#
|
||||
# The first line defines the option `-h`/`--help`. With most tools, it isn't
|
||||
# useful to complete anything after `--help` because it effectively overrides
|
||||
# all others; the `(: * -)` at the beginning of the spec tells zsh not to
|
||||
# complete any other operands (`:` and `*`) or options (`-`) after this one has
|
||||
# been used. The `[...]` at the end associates a description with `-h`/`--help`;
|
||||
# as mentioned, zsh will see the identical descriptions and merge these options
|
||||
# together when offering completion possibilities.
|
||||
#
|
||||
# The next line defines `-q`/`--quiet`. Here we don't want to suppress further
|
||||
# completions entirely, but we don't want to offer `-q` if `--quiet` has been
|
||||
# given (since they do the same thing), nor do we want to offer `-v` (since it
|
||||
# doesn't make sense to be quiet and verbose at the same time). We don't need to
|
||||
# tell zsh not to offer `--quiet` a second time, since that's the default
|
||||
# behaviour, but since this line expands to two specs describing `-q` *and*
|
||||
# `--quiet` we do need to explicitly list all of them here.
|
||||
#
|
||||
# The next line defines a hidden option `--silent` — maybe it's a deprecated
|
||||
# synonym for `--quiet`. The leading `!` indicates that zsh shouldn't offer this
|
||||
# option during completion. The benefit of providing a spec for an option that
|
||||
# shouldn't be completed is that, if someone *does* use it, we can correctly
|
||||
# suppress completion of other options afterwards.
|
||||
#
|
||||
# The next line defines `-v`/`--verbose`; this works just like `-q`/`--quiet`.
|
||||
#
|
||||
# The next line defines `--color`. In this example, `--color` doesn't have a
|
||||
# corresponding short option, so we don't need to use brace expansion. Further,
|
||||
# there are no other options it's exclusive with (just itself), so we don't need
|
||||
# to define those at the beginning. However, it does take a mandatory argument.
|
||||
# The `=` at the end of `--color=` indicates that the argument may appear either
|
||||
# like `--color always` or like `--color=always`; this is how most GNU-style
|
||||
# command-line tools work. The corresponding short option would normally use `+`
|
||||
# — for example, `-c+` would allow either `-c always` or `-calways`. For this
|
||||
# option, the arguments are known ahead of time, so we can simply list them in
|
||||
# parentheses at the end (`when` is used as the description for the argument).
|
||||
#
|
||||
# The last line defines an operand (a non-option argument). In this example, the
|
||||
# operand can be used any number of times (the leading `*`), and it should be a
|
||||
# file path, so we tell zsh to call the `_files` function to complete it. The
|
||||
# `example file` in the middle is the description to use for this operand; we
|
||||
# could use a space instead to accept the default provided by `_files`.
|
||||
#
|
||||
# GROUPING ARGUMENT SPECIFICATIONS
|
||||
#
|
||||
# Newer versions of zsh support grouping argument specs together. All specs
|
||||
# following a `+` and then a group name are considered to be members of the
|
||||
# named group. Grouping is useful mostly for organisational purposes; it makes
|
||||
# the relationship between different options more obvious, and makes it easier
|
||||
# to specify exclusions.
|
||||
#
|
||||
# We could rewrite our example above using grouping as follows:
|
||||
#
|
||||
# '(: * -)'{-h,--help}'[display help information]'
|
||||
# '--color=[specify when to use colors]:when:(always never auto)'
|
||||
# '*:example file:_files'
|
||||
# + '(verbosity)'
|
||||
# {-q,--quiet}'[decrease output verbosity]'
|
||||
# '!--silent'
|
||||
# {-v,--verbose}'[increase output verbosity]'
|
||||
#
|
||||
# Here we take advantage of a useful feature of spec grouping — when the group
|
||||
# name is surrounded by parentheses, as in `(verbosity)`, it tells zsh that all
|
||||
# of the options in that group are exclusive with each other. As a result, we
|
||||
# don't need to manually list out the exclusions at the beginning of each
|
||||
# option.
|
||||
#
|
||||
# Groups can also be referred to by name in other argument specs; for example:
|
||||
#
|
||||
# '(xyz)--aaa' '*: :_files'
|
||||
# + xyz --xxx --yyy --zzz
|
||||
#
|
||||
# Here we use the group name `xyz` to tell zsh that `--xxx`, `--yyy`, and
|
||||
# `--zzz` are not to be completed after `--aaa`. This makes the exclusion list
|
||||
# much more compact and reusable.
|
||||
#
|
||||
# CONVENTIONS
|
||||
#
|
||||
# zsh completion functions generally adhere to the following conventions:
|
||||
#
|
||||
# * Use two spaces for indentation
|
||||
# * Combine specs for options with different names using brace expansion
|
||||
# * In combined specs, list the short option first (as in `{-a,--text}`)
|
||||
# * Use `+` or `=` as described above for options that take arguments
|
||||
# * Provide a description for all options, option-arguments, and operands
|
||||
# * Capitalise/punctuate argument descriptions as phrases, not complete
|
||||
# sentences — 'display help information', never 'Display help information.'
|
||||
# (but still capitalise acronyms and proper names)
|
||||
# * Write argument descriptions as verb phrases — 'display x', 'enable y',
|
||||
# 'use z'
|
||||
# * Word descriptions to make it clear when an option expects an argument;
|
||||
# usually this is done with the word 'specify', as in 'specify x' or
|
||||
# 'use specified x')
|
||||
# * Write argument descriptions as tersely as possible — for example, articles
|
||||
# like 'a' and 'the' should be omitted unless it would be confusing
|
||||
#
|
||||
# Other conventions currently used by this function:
|
||||
#
|
||||
# * Order argument specs alphabetically by group name, then option name
|
||||
# * Group options that are directly related, mutually exclusive, or frequently
|
||||
# referenced by other argument specs
|
||||
# * Use only characters in the set [a-z0-9_-] in group names
|
||||
# * Order exclusion lists as follows: short options, long options, groups
|
||||
# * Use American English in descriptions
|
||||
# * Use 'don't' in descriptions instead of 'do not'
|
||||
# * Word descriptions for related options as similarly as possible. For example,
|
||||
# `--foo[enable foo]` and `--no-foo[disable foo]`, or `--foo[use foo]` and
|
||||
# `--no-foo[don't use foo]`
|
||||
# * Word descriptions to make it clear when an option only makes sense with
|
||||
# another option, usually by adding '(with -x)' to the end
|
||||
# * Don't quote strings or variables unnecessarily. When quotes are required,
|
||||
# prefer single-quotes to double-quotes
|
||||
# * Prefix option specs with `$no` when the option serves only to negate the
|
||||
# behaviour of another option that must be provided explicitly by the user.
|
||||
# This prevents rarely used options from cluttering up the completion menu
|
||||
################################################################################
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2011 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 ripgrep
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * arcizan <ghostrevery@gmail.com>
|
||||
# * MaskRay <i@maskray.me>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# coding: utf-8-unix
|
||||
# indent-tabs-mode: nil
|
||||
# sh-indentation: 2
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
65
.config/zsh/config/completions/completions/_shellcheck
Normal file
65
.config/zsh/config/completions/completions/_shellcheck
Normal file
@ -0,0 +1,65 @@
|
||||
#compdef shellcheck
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2021 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 shellcheck (https://github.com/koalaman/shellcheck)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Khue Nguyen (https://github.com/Z5483)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_arguments \
|
||||
{-a,--check-sourced}'[include warnings from sourced file]' \
|
||||
{-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' \
|
||||
{-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]" \
|
||||
{-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,--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' \
|
||||
{-x,--external-sources}'[allow outside sources]' \
|
||||
'--help[show this usage summary and exit]' \
|
||||
'*: :_files'
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
260
.config/zsh/config/completions/completions/_vagrant
Normal file
260
.config/zsh/config/completions/completions/_vagrant
Normal file
@ -0,0 +1,260 @@
|
||||
#compdef vagrant
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2009-2015 Robby Russell and contributors (see
|
||||
# https://github.com/robbyrussell/oh-my-zsh/contributors)
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for Vagrant (http://vagrantup.com).
|
||||
#
|
||||
# Source: https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/vagrant
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Nikita Fedyashev (https://github.com/nfedyashev)
|
||||
# * Mark Cornick (https://github.com/markcornick)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# vagrant zsh completion
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'box:Box commands'
|
||||
'connect:Connects to a shared, remote Vagrant environment'
|
||||
'destroy:Destroys the vagrant environment'
|
||||
'docker-logs:Shows Docker logs'
|
||||
'docker-run:Run one-off commands against a Docker container'
|
||||
'global-status:Reports the status of all active Vagrant environments on the system'
|
||||
'halt:Halts the currently running vagrant environment'
|
||||
'help:[TASK] Describe available tasks or one specific task'
|
||||
'init:[box_name] [box_url] Initializes current folder for Vagrant usage'
|
||||
'list-commands:Outputs all available Vagrant subcommands'
|
||||
'login:Authenticates against a Vagrant Cloud server to access protected boxes'
|
||||
'package:Packages a vagrant environment for distribution'
|
||||
'plugin:Manage plugins'
|
||||
'provision:Run the provisioner'
|
||||
'push:Deploys code in this environment to a configured destination'
|
||||
'rdp:Connects to machine via RDP'
|
||||
'reload:Reload the vagrant environment'
|
||||
'resume:Resumes a suspend vagrant environment'
|
||||
'rsync:Syncs rsync synced folders to remote machine'
|
||||
'rsync-auto:Syncs rsync synced folders automatically when files change'
|
||||
'share:Shares the Vagrant environment and allows remote access'
|
||||
'ssh:SSH into the currently running environment'
|
||||
'ssh-config:Outputs .ssh/config valid syntax for connecting to this environment via ssh'
|
||||
'status:Shows the status of the current Vagrant environment'
|
||||
'suspend:Suspends the currently running vagrant environment'
|
||||
'up:Creates the vagrant environment'
|
||||
'version:Prints the currently installed Vagrant version and checks for new updates'
|
||||
'--version:Prints the Vagrant version information'
|
||||
)
|
||||
|
||||
local -a _box_arguments
|
||||
_box_arguments=(
|
||||
'add:NAME URI Add a box to the system'
|
||||
'help:COMMAND Describe subcommands or one specific subcommand'
|
||||
'list:Lists all installed boxes'
|
||||
'outdated:Checks if there is a new version available for the box'
|
||||
'remove:NAME Remove a box from the system'
|
||||
'repackage:NAME Repackage an installed box into a `.box` file.'
|
||||
'update:Updates the box, if there any updates available'
|
||||
)
|
||||
|
||||
local -a _plugin_arguments
|
||||
_plugin_arguments=(
|
||||
'install:NAME Install a plugin to the system'
|
||||
'license:NAME LICENSE_FILE Add a license for an installed plugin'
|
||||
'list:Lists all installed plugins'
|
||||
'uninstall:NAME Uninstall a plugin from the system'
|
||||
'update:[NAMES...] Update all or specified plugins'
|
||||
)
|
||||
|
||||
__task_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a tasks
|
||||
|
||||
tasks=(box destroy global-status halt init package plugin provision \
|
||||
reload resume ssh ssh_config status suspend up version)
|
||||
|
||||
_wanted tasks expl 'help' compadd $tasks
|
||||
}
|
||||
|
||||
__box_list ()
|
||||
{
|
||||
_wanted application expl 'command' compadd $(command vagrant box list | \
|
||||
awk '{print $1}' | \
|
||||
sed -e 's/ /\\ /g')
|
||||
}
|
||||
|
||||
__plugin_list ()
|
||||
{
|
||||
_wanted application expl 'command' compadd $(command vagrant plugin list \
|
||||
2>/dev/null| cut -d' ' -f1)
|
||||
}
|
||||
|
||||
_vagrant_caching_policy()
|
||||
{
|
||||
local reg_time comp_time check_file
|
||||
|
||||
case "${1##*/}" in
|
||||
VAGRANT_VMS)
|
||||
if [[ -z $VAGRANT_CWD ]]; then
|
||||
check_file=./Vagrantfile
|
||||
else
|
||||
check_file=$VAGRANT_CWD/Vagrantfile
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "unknown type: $1"
|
||||
return -1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$OSTYPE" in
|
||||
darwin*) STATCMD="/usr/bin/stat -f '%c'" ;;
|
||||
*) STATCMD="stat -c '%Z'" ;;
|
||||
esac
|
||||
reg_time=${$(${(z)STATCMD} $check_file):Q}
|
||||
comp_time=${$(${(z)STATCMD} $1):Q}
|
||||
|
||||
return $(( reg_time < comp_time ))
|
||||
}
|
||||
|
||||
__vm_list ()
|
||||
{
|
||||
local cache_policy
|
||||
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
|
||||
zstyle ":completion:${curcontext}:" cache-policy \
|
||||
${cache_policy:-_vagrant_caching_policy}
|
||||
|
||||
# Cache the list of VMs available
|
||||
if ( [[ ${+_vagrant_vms} -eq 0 ]] || _cache_invalid VAGRANT_VMS ) &&
|
||||
! _retrieve_cache VAGRANT_VMS;
|
||||
then
|
||||
_vagrant_vms=( $(_call_program path-all "vagrant status | \
|
||||
awk '{print \$1}' | \
|
||||
egrep -v '^$|^(Current|This|above|VM,)$'" ) )
|
||||
_store_cache VAGRANT_VMS _vagrant_vms
|
||||
fi
|
||||
|
||||
_wanted application expl 'command' compadd $_vagrant_vms
|
||||
}
|
||||
|
||||
__vagrant-box ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "gem subcommand" _box_arguments
|
||||
return
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
(repackage|remove)
|
||||
_arguments ':feature:__box_list'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__vagrant-plugin ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
local -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "gem subcommand" _plugin_arguments
|
||||
return
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
(license)
|
||||
_arguments ':feature:__plugin_list' '*:file:_files'
|
||||
;;
|
||||
(uninstall)
|
||||
_arguments ':feature:__plugin_list'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
local expl
|
||||
local -a boxes installed_boxes
|
||||
|
||||
local curcontext="$curcontext" state line
|
||||
local -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "gem subcommand" _1st_arguments
|
||||
return
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
(help)
|
||||
_arguments ':feature:__task_list'
|
||||
;;
|
||||
|
||||
(box)
|
||||
__vagrant-box
|
||||
;;
|
||||
|
||||
(plugin)
|
||||
__vagrant-plugin
|
||||
;;
|
||||
(up|provision|package|destroy|reload|ssh|halt|resume|status|suspend)
|
||||
_arguments ':feature:__vm_list'
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
# 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
|
389
.config/zsh/config/completions/completions/_wezterm
Normal file
389
.config/zsh/config/completions/completions/_wezterm
Normal file
@ -0,0 +1,389 @@
|
||||
#compdef wezterm
|
||||
|
||||
autoload -U is-at-least
|
||||
|
||||
_wezterm() {
|
||||
typeset -A opt_args
|
||||
typeset -a _arguments_options
|
||||
local ret=1
|
||||
|
||||
if is-at-least 5.2; then
|
||||
_arguments_options=(-s -S -C)
|
||||
else
|
||||
_arguments_options=(-s -C)
|
||||
fi
|
||||
|
||||
local context curcontext="$curcontext" state line
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'(-n)--config-file=[Specify the configuration file to use, overrides the normal configuration file resolution]:CONFIG_FILE:_files' \
|
||||
'*--config=[Override specific configuration values]:name=value: ' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
'-V[Print version information]' \
|
||||
'--version[Print version information]' \
|
||||
'-n[Skip loading wezterm.lua]' \
|
||||
":: :_wezterm_commands" \
|
||||
"*::: :->wezterm" \
|
||||
&& ret=0
|
||||
case $state in
|
||||
(wezterm)
|
||||
words=($line[1] "${words[@]}")
|
||||
(( CURRENT += 1 ))
|
||||
curcontext="${curcontext%:*:*}:wezterm-command-$line[1]:"
|
||||
case $line[1] in
|
||||
(start)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--cwd=[Specify the current working directory for the initially spawned program]:CWD:_files -/' \
|
||||
'--class=[Override the default windowing system class. The default is "org.wezfurlong.wezterm". Under X11 and Windows this changes the window class. Under Wayland this changes the app_id. This changes the class for all windows spawned by this instance of wezterm, including error, update and ssh authentication dialogs]:CLASS: ' \
|
||||
'--workspace=[Override the default workspace with the provided name. The default is "default"]:WORKSPACE: ' \
|
||||
'--position=[Override the position for the initial window launched by this process.]:POSITION: ' \
|
||||
'--no-auto-connect[If true, do not connect to domains marked as connect_automatically in your wezterm configuration file]' \
|
||||
'--always-new-process[If enabled, don'\''t try to ask an existing wezterm GUI instance to start the command. Instead, always start the GUI in this invocation of wezterm so that you can wait for the command to complete by waiting for this wezterm process to finish]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm start -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \
|
||||
&& ret=0
|
||||
;;
|
||||
(ssh)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'*-o+[Override specific SSH configuration options. `wezterm ssh` is able to parse some (but not all!) options from your `~/.ssh/config` and `/etc/ssh/ssh_config` files. This command line switch allows you to override or otherwise specify ssh_config style options]:name=value: ' \
|
||||
'*--ssh-option=[Override specific SSH configuration options. `wezterm ssh` is able to parse some (but not all!) options from your `~/.ssh/config` and `/etc/ssh/ssh_config` files. This command line switch allows you to override or otherwise specify ssh_config style options]:name=value: ' \
|
||||
'--class=[Override the default windowing system class. The default is "org.wezfurlong.wezterm". Under X11 and Windows this changes the window class. Under Wayland this changes the app_id. This changes the class for all windows spawned by this instance of wezterm, including error, update and ssh authentication dialogs]:CLASS: ' \
|
||||
'--position=[Override the position for the initial window launched by this process.]:POSITION: ' \
|
||||
'-v[Enable verbose ssh protocol tracing. The trace information is printed to the stderr stream of the process]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
':user-at-host-and-port -- Specifies the remote system using the form\: `\[username@\]host\[\:port\]`. If `username@` is omitted, then your local $USER is used instead. If `\:port` is omitted, then the standard ssh port (22) is used instead:' \
|
||||
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm ssh user@host -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \
|
||||
&& ret=0
|
||||
;;
|
||||
(serial)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--baud=[Set the baud rate. The default is 9600 baud]:BAUD: ' \
|
||||
'--class=[Override the default windowing system class. The default is "org.wezfurlong.wezterm". Under X11 and Windows this changes the window class. Under Wayland this changes the app_id. This changes the class for all windows spawned by this instance of wezterm, including error, update and ssh authentication dialogs]:CLASS: ' \
|
||||
'--position=[Override the position for the initial window launched by this process.]:POSITION: ' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
':port -- Specifies the serial device name. On Windows systems this can be a name like `COM0`. On posix systems this will be something like `/dev/ttyUSB0`:' \
|
||||
&& ret=0
|
||||
;;
|
||||
(connect)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--class=[Override the default windowing system class. The default is "org.wezfurlong.wezterm". Under X11 and Windows this changes the window class. Under Wayland this changes the app_id. This changes the class for all windows spawned by this instance of wezterm, including error, update and ssh authentication dialogs]:CLASS: ' \
|
||||
'--workspace=[Override the default workspace with the provided name. The default is "default"]:WORKSPACE: ' \
|
||||
'--position=[Override the position for the initial window launched by this process.]:POSITION: ' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
':domain-name -- Name of the multiplexer domain section from the configuration to which you'\''d like to connect:' \
|
||||
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm start -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \
|
||||
&& ret=0
|
||||
;;
|
||||
(ls-fonts)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'(--list-system)--text=[Explain which fonts are used to render the supplied text string]:TEXT: ' \
|
||||
'--list-system[Whether to list all fonts available to the system]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(show-keys)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(cli)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--class=[When connecting to a gui instance, if you started the gui with `--class SOMETHING`, you should also pass that same value here in order for the client to find the correct gui instance]:CLASS: ' \
|
||||
'--no-auto-start[Don'\''t automatically start the server]' \
|
||||
'--prefer-mux[Prefer connecting to a background mux server. The default is to prefer connecting to a running wezterm gui instance]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
":: :_wezterm__cli_commands" \
|
||||
"*::: :->cli" \
|
||||
&& ret=0
|
||||
|
||||
case $state in
|
||||
(cli)
|
||||
words=($line[1] "${words[@]}")
|
||||
(( CURRENT += 1 ))
|
||||
curcontext="${curcontext%:*:*}:wezterm-cli-command-$line[1]:"
|
||||
case $line[1] in
|
||||
(list)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--format=[Controls the output format. "table" and "json" are possible formats]:FORMAT: ' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(list-clients)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--format=[Controls the output format. "table" and "json" are possible formats]:FORMAT: ' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(proxy)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(tlscreds)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(move-pane-to-new-tab)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--pane-id=[Specify the pane that should be moved. The default is to use the current pane based on the environment variable WEZTERM_PANE]:PANE_ID: ' \
|
||||
'--window-id=[Specify the window into which the new tab will be created. If omitted, the window associated with the current pane is used]:WINDOW_ID: ' \
|
||||
'--workspace=[If creating a new window, override the default workspace name with the provided name. The default name is "default"]:WORKSPACE: ' \
|
||||
'(--window-id)--new-window[Create tab in a new window, rather than the window currently containing the pane]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(split-pane)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--pane-id=[Specify the pane that should be split. The default is to use the current pane based on the environment variable WEZTERM_PANE]:PANE_ID: ' \
|
||||
'--cells=[The number of cells that the new split should have. If omitted, 50% of the available space is used]:CELLS: ' \
|
||||
'(--cells)--percent=[Specify the number of cells that the new split should have, expressed as a percentage of the available space]:PERCENT: ' \
|
||||
'--cwd=[Specify the current working directory for the initially spawned program]:CWD:_files -/' \
|
||||
'(--cwd)--move-pane-id=[Instead of spawning a new command, move the specified pane into the newly created split]:MOVE_PANE_ID: ' \
|
||||
'(--left --right --top --bottom)--horizontal[Equivalent to `--right`. If neither this nor any other direction is specified, the default is equivalent to `--bottom`]' \
|
||||
'(--right --top --bottom)--left[Split horizontally, with the new pane on the left]' \
|
||||
'(--left --top --bottom)--right[Split horizontally, with the new pane on the right]' \
|
||||
'(--left --right --bottom)--top[Split vertically, with the new pane on the top]' \
|
||||
'(--left --right --top)--bottom[Split vertically, with the new pane on the bottom]' \
|
||||
'--top-level[Rather than splitting the active pane, split the entire window]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm cli split-pane -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \
|
||||
&& ret=0
|
||||
;;
|
||||
(spawn)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--pane-id=[Specify the current pane. The default is to use the current pane based on the environment variable WEZTERM_PANE. The pane is used to determine the current domain and window]:PANE_ID: ' \
|
||||
'--domain-name=[]:DOMAIN_NAME: ' \
|
||||
'--window-id=[Specify the window into which to spawn a tab. If omitted, the window associated with the current pane is used]:WINDOW_ID: ' \
|
||||
'--cwd=[Specify the current working directory for the initially spawned program]:CWD:_files -/' \
|
||||
'--workspace=[When creating a new window, override the default workspace name with the provided name. The default name is "default"]:WORKSPACE: ' \
|
||||
'(--window-id)--new-window[Spawn into a new window, rather than a new tab]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm cli spawn -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \
|
||||
&& ret=0
|
||||
;;
|
||||
(send-text)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--pane-id=[Specify the target pane. The default is to use the current pane based on the environment variable WEZTERM_PANE]:PANE_ID: ' \
|
||||
'--no-paste[Send the text directly, rather than as a bracketed paste]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
'::text -- The text to send. If omitted, will read the text from stdin:' \
|
||||
&& ret=0
|
||||
;;
|
||||
(help)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'*::subcommand -- The subcommand whose help message to display:' \
|
||||
&& ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(imgcat)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--width=[Specify the display width; defaults to "auto" which automatically selects an appropriate size. You may also use an integer value `N` to specify the number of cells, or `Npx` to specify the number of pixels, or `N%` to size relative to the terminal width]:WIDTH: ' \
|
||||
'--height=[Specify the display height; defaults to "auto" which automatically selects an appropriate size. You may also use an integer value `N` to specify the number of cells, or `Npx` to specify the number of pixels, or `N%` to size relative to the terminal height]:HEIGHT: ' \
|
||||
'--no-preserve-aspect-ratio[Do not respect the aspect ratio. The default is to respect the aspect ratio]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
'::file-name -- The name of the image file to be displayed. If omitted, will attempt to read it from stdin:_files' \
|
||||
&& ret=0
|
||||
;;
|
||||
(set-working-directory)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
'::cwd -- The directory to specify. If omitted, will use the current directory of the process itself:_files -/' \
|
||||
'::host -- The hostname to use in the constructed file\:// URL. If omitted, the system hostname will be used:_hosts' \
|
||||
&& ret=0
|
||||
;;
|
||||
(record)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
'*::prog:' \
|
||||
&& ret=0
|
||||
;;
|
||||
(replay)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--explain[Explain what is being sent/received]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
':cast-file:' \
|
||||
&& ret=0
|
||||
;;
|
||||
(shell-completion)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--shell=[Which shell to generate for]:SHELL:(bash elvish fish powershell zsh)' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(help)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'*::subcommand -- The subcommand whose help message to display:' \
|
||||
&& ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
(( $+functions[_wezterm_commands] )) ||
|
||||
_wezterm_commands() {
|
||||
local commands; commands=(
|
||||
'start:Start the GUI, optionally running an alternative program' \
|
||||
'ssh:Establish an ssh session' \
|
||||
'serial:Open a serial port' \
|
||||
'connect:Connect to wezterm multiplexer' \
|
||||
'ls-fonts:Display information about fonts' \
|
||||
'show-keys:Show key assignments' \
|
||||
'cli:Interact with experimental mux server' \
|
||||
'imgcat:Output an image to the terminal' \
|
||||
'set-working-directory:Advise the terminal of the current working directory by emitting an OSC 7 escape sequence' \
|
||||
'record:Record a terminal session as an asciicast' \
|
||||
'replay:Replay an asciicast terminal session' \
|
||||
'shell-completion:Generate shell completion information' \
|
||||
'help:Print this message or the help of the given subcommand(s)' \
|
||||
)
|
||||
_describe -t commands 'wezterm commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__cli_commands] )) ||
|
||||
_wezterm__cli_commands() {
|
||||
local commands; commands=(
|
||||
'list:list windows, tabs and panes' \
|
||||
'list-clients:list clients' \
|
||||
'proxy:start rpc proxy pipe' \
|
||||
'tlscreds:obtain tls credentials' \
|
||||
'move-pane-to-new-tab:Move a pane into a new tab' \
|
||||
'split-pane:split the current pane.
|
||||
Outputs the pane-id for the newly created pane on success' \
|
||||
'spawn:Spawn a command into a new window or tab
|
||||
Outputs the pane-id for the newly created pane on success' \
|
||||
'send-text:Send text to a pane as though it were pasted. If bracketed paste mode is enabled in the pane, then the text will be sent as a bracketed paste' \
|
||||
'help:Print this message or the help of the given subcommand(s)' \
|
||||
)
|
||||
_describe -t commands 'wezterm cli commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__connect_commands] )) ||
|
||||
_wezterm__connect_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm connect commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__cli__help_commands] )) ||
|
||||
_wezterm__cli__help_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm cli help commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__help_commands] )) ||
|
||||
_wezterm__help_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm help commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__imgcat_commands] )) ||
|
||||
_wezterm__imgcat_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm imgcat commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__cli__list_commands] )) ||
|
||||
_wezterm__cli__list_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm cli list commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__cli__list-clients_commands] )) ||
|
||||
_wezterm__cli__list-clients_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm cli list-clients commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__ls-fonts_commands] )) ||
|
||||
_wezterm__ls-fonts_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm ls-fonts commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__cli__move-pane-to-new-tab_commands] )) ||
|
||||
_wezterm__cli__move-pane-to-new-tab_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm cli move-pane-to-new-tab commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__cli__proxy_commands] )) ||
|
||||
_wezterm__cli__proxy_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm cli proxy commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__record_commands] )) ||
|
||||
_wezterm__record_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm record commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__replay_commands] )) ||
|
||||
_wezterm__replay_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm replay commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__cli__send-text_commands] )) ||
|
||||
_wezterm__cli__send-text_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm cli send-text commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__serial_commands] )) ||
|
||||
_wezterm__serial_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm serial commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__set-working-directory_commands] )) ||
|
||||
_wezterm__set-working-directory_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm set-working-directory commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__shell-completion_commands] )) ||
|
||||
_wezterm__shell-completion_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm shell-completion commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__show-keys_commands] )) ||
|
||||
_wezterm__show-keys_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm show-keys commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__cli__spawn_commands] )) ||
|
||||
_wezterm__cli__spawn_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm cli spawn commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__cli__split-pane_commands] )) ||
|
||||
_wezterm__cli__split-pane_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm cli split-pane commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__ssh_commands] )) ||
|
||||
_wezterm__ssh_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm ssh commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__start_commands] )) ||
|
||||
_wezterm__start_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm start commands' commands "$@"
|
||||
}
|
||||
(( $+functions[_wezterm__cli__tlscreds_commands] )) ||
|
||||
_wezterm__cli__tlscreds_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'wezterm cli tlscreds commands' commands "$@"
|
||||
}
|
||||
|
||||
_wezterm "$@"
|
502
.config/zsh/config/completions/completions/_yarn
Normal file
502
.config/zsh/config/completions/completions/_yarn
Normal file
@ -0,0 +1,502 @@
|
||||
#compdef yarn
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 yarn (https://yarnpkg.com/)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
|
||||
# * Shohei YOSHIDA <syohex@gmail.com>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
declare -g _yarn_run_cwd
|
||||
|
||||
_commands=(
|
||||
'access'
|
||||
'audit:Checks for known security issues with the installed packages'
|
||||
'autoclean:Clean and remove unnecessary files from package dependencies'
|
||||
'cache:List or clean every cached package'
|
||||
"check:Verify package dependencies against yarn's lock file"
|
||||
'config:Manages the yarn configuration files'
|
||||
'create:Creates new projects from any create-* starter kits'
|
||||
'exec'
|
||||
'generate-lock-entry:Generates a lock file entry'
|
||||
'global:Install packages globally on your operating system'
|
||||
'help:Show information about a command'
|
||||
'import:Generate yarn.lock from an existing npm-installed node_modules folder'
|
||||
'info:Show information about a package'
|
||||
'init:Interactively creates or updates a package.json file'
|
||||
'install:Install all the dependencies listed within package.json'
|
||||
'licenses:List licenses for installed packages'
|
||||
'link:Symlink a package folder during development'
|
||||
'login:Store registry username and email'
|
||||
'logout:Clear registry username and email'
|
||||
'node:Runs Node with the same version that the one used by Yarn itself'
|
||||
'outdated:Check for outdated package dependencies'
|
||||
'owner:Manage package owners'
|
||||
'pack:Create a compressed gzip archive of package dependencies'
|
||||
'policies:Defines project-wide policies for your project'
|
||||
'publish:Publish a package to the npm registry'
|
||||
'run:Run a defined package script'
|
||||
'tag:Add, remove, or list tags on a package'
|
||||
'team:Maintain team memberships'
|
||||
'unlink:Unlink a previously created symlink for a package'
|
||||
'unplug:Temporarily copies a package outside of the global cache for debugging purposes'
|
||||
'version:Update the package version'
|
||||
'versions:Display version information of currently installed Yarn, Node.js, and its dependencies'
|
||||
'why:Show information about why a package is installed'
|
||||
'workspace'
|
||||
'workspaces:Show information about your workspaces'
|
||||
)
|
||||
|
||||
_global_commands=(
|
||||
'add:Installs a package and any packages that it depends on'
|
||||
'bin:Displays the location of the yarn bin folder'
|
||||
'list:List installed packages'
|
||||
'remove:Remove installed package from dependencies updating package.json'
|
||||
'upgrade:Upgrades packages to their latest version based on the specified range'
|
||||
'upgrade-interactive:Interactively upgrade packages'
|
||||
)
|
||||
|
||||
_yarn_find_package_json() {
|
||||
local dir=$(cd "$1" && pwd)
|
||||
|
||||
while true
|
||||
do
|
||||
if [[ -e "${dir}/package.json" ]]; then
|
||||
echo "${dir}/package.json"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ $dir == '/' ]]; then
|
||||
break
|
||||
fi
|
||||
|
||||
dir=$(dirname $dir)
|
||||
done
|
||||
}
|
||||
|
||||
_yarn_commands_scripts() {
|
||||
local -a scripts binaries
|
||||
local packageJson
|
||||
|
||||
if [[ -n $opt_args[--cwd] ]]; then
|
||||
packageJson=$(_yarn_find_package_json $opt_args[--cwd])
|
||||
binaries=($(cd $opt_args[--cwd] && echo node_modules/.bin/*(x:t)))
|
||||
else
|
||||
packageJson=$(_yarn_find_package_json $pwd)
|
||||
binaries=($(echo node_modules/.bin/*(x:t)))
|
||||
fi
|
||||
|
||||
if [[ -n $packageJson ]]; then
|
||||
scripts=($(cat "$packageJson" | perl -0777 -MJSON::PP -n -E '$r=decode_json($_); do{($k=$_)=~s/:/\\:/g;say $k}for sort keys %{$r->{scripts}}'))
|
||||
fi
|
||||
|
||||
_describe 'command or script' _commands -- _global_commands -- scripts -- binaries
|
||||
}
|
||||
|
||||
_yarn_scripts() {
|
||||
local -a binaries scripts
|
||||
local -a commands
|
||||
local packageJson
|
||||
|
||||
if [[ -n $_yarn_run_cwd ]]; then
|
||||
packageJson=$(_yarn_find_package_json $_yarn_run_cwd)
|
||||
if [[ -d "${_yarn_run_cwd}/node_modules" ]]; then
|
||||
binaries=($(cd $_yarn_run_cwd && echo node_modules/.bin/*(x:t)))
|
||||
else
|
||||
binaries=($(cd $_yarn_run_cwd && yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1'))
|
||||
fi
|
||||
else
|
||||
packageJson=$(_yarn_find_package_json $pwd)
|
||||
if [[ -d node_modules ]]; then
|
||||
binaries=($(echo node_modules/.bin/*(x:t)))
|
||||
else
|
||||
binaries=($(yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1'))
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n $packageJson ]]; then
|
||||
scripts=("${(@f)$(cat ${packageJson} | perl -0777 -MJSON::PP -n -E '%r=%{decode_json($_)->{scripts}}; do{$k=$_;($e=$k)=~s/:/\\:/g; printf "$e:$r{$k}\n"} for sort keys %r')}")
|
||||
fi
|
||||
|
||||
commands=('env' $scripts $binaries)
|
||||
_describe 'command' commands
|
||||
}
|
||||
|
||||
_yarn_global_commands() {
|
||||
local -a cmds
|
||||
cmds=('ls:List installed packages')
|
||||
_describe 'command' _global_commands
|
||||
}
|
||||
|
||||
_yarn_commands() {
|
||||
_describe 'command' _commands -- _global_commands
|
||||
}
|
||||
|
||||
_yarn_add_files() {
|
||||
if compset -P "(file|link):"; then
|
||||
_files
|
||||
fi
|
||||
}
|
||||
|
||||
_yarn_workspaces() {
|
||||
local version=$(yarn --version |sed -n 's|\([0-9]*\).*|\1|p')
|
||||
local -a workspaces
|
||||
if [[ $version == "1" ]]; then
|
||||
workspaces=(${(@f)$(yarn workspaces info |sed -n -e 's/^ "\([^"]*\)": {/\1/p')})
|
||||
else
|
||||
workspaces=(${(@f)$(yarn workspaces list --json | sed -n 's|.*"name":"\([^"]*\)"}|\1|p')})
|
||||
fi
|
||||
_describe 'workspace' workspaces
|
||||
}
|
||||
|
||||
_yarn() {
|
||||
local context state state_descr line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments \
|
||||
'(-h --help)'{-h,--help}'[output usage information]' \
|
||||
'(-V --version)'{-V,--version}'[output the version number]' \
|
||||
'--verbose[output verbose messages on internal operations]' \
|
||||
'--cache-folder=[specify a custom folder to store the yarn cache]:folder:_files -/' \
|
||||
'--check-files[install will verify file tree of packages for consistency]' \
|
||||
'--cwd=[working directory to use]:path:_files -/' \
|
||||
"(--enable-pnp --pnp)--disable-pnp[disable the Plug'n'Play installation]" \
|
||||
'(--no-emoji)--emoji=[enable emoji in output(default: false)]:enabled:(true false)' \
|
||||
'(--emoji)--no-emoji[disable emoji in output]' \
|
||||
'(--disable-pnp)'{--enable-pnp,--pnp}"[enable the Plug'n'Play installation]" \
|
||||
'--flat[only allow one version of a package]' \
|
||||
'--focus[Focus on a single workspace by installing remote copies of its sibling workspaces]' \
|
||||
'--force[install and build packages even if they were built before, overwrite lockfile]' \
|
||||
"--frozen-lockfile[don't generate a lockfile and fail if an update is needed]" \
|
||||
'--global-folder=[modules folder]:folder:_files -/' \
|
||||
'--har[save HAR output of network traffic]' \
|
||||
'--https-proxy=[HTTPS proxy]:host:_hosts' \
|
||||
'--ignore-engines[ignore engines check]' \
|
||||
"--ignore-scripts[don't run lifecycle scripts]" \
|
||||
'--ignore-optional[ignore optional dependencies]' \
|
||||
'--ignore-platform[ignore platform checks]' \
|
||||
'--json[format Yarn log messages as lines of JSON]' \
|
||||
'--link-duplicates[create hardlinks to the repeated modules in node_modules]' \
|
||||
'--link-folder=[specify a custom folder to store global links]' \
|
||||
'--modules-folder=[rather than installing modules into the node_modules folder relative to the cwd, output them here]:folder:_files -/' \
|
||||
'--mutex=[use a mutex to ensure only one yarn instance is executing]:type[\:specifier]' \
|
||||
'--network-concurrency=[maximum number of concurrent network requests]:number' \
|
||||
'--network-timeout=[TCP timeout for network requests]:milliseconds' \
|
||||
"--no-bin-links[don't generate bin links when setting up packages]" \
|
||||
'--no-default-rc[prevent Yarn from automatically detecting yarnrc and npmrc files]' \
|
||||
"--no-lockfile[don't read or generate a lockfile]" \
|
||||
'--non-interactive[do not show interactive prompts]' \
|
||||
'--no-node-version-check[do not warn when using a potentially unsupported Node version]' \
|
||||
'--no-progress[disable progress bar]' \
|
||||
'--offline[trigger an error if any required dependencies are not available in local cache]' \
|
||||
'--otp=[one-time password for two factor authentication]:otpcode' \
|
||||
'--prefer-offline[use network only if dependencies are not available in local cache]' \
|
||||
'--preferred-cache-folder=[specify a custom folder to store the yarn cache if possible]:folder:_files -/' \
|
||||
'(--prod --production)'{--prod,--production}'[install only production dependencies]' \
|
||||
'--proxy=[HTTP proxy]:host:_hosts' \
|
||||
"--pure-lockfile[don't generate a lockfile]" \
|
||||
'--registry=[override configuration registry]:url:_urls' \
|
||||
'(-s --silent)'{-s,--silent}'[skip Yarn console logs, other types of logs (script output) will be printed]' \
|
||||
'--scripts-prepend-node-path=[prepend the node executable dir to the PATH in scripts]:bool:(true false)' \
|
||||
'--skip-integrity-check[run install without checking if node_modules is installed]' \
|
||||
"--strict-semver[don't compare semver loosely]" \
|
||||
'--update-checksum[update package checksums from current repository]' \
|
||||
'--use-yarnrc=[specifies a yarnrc that Yarn should use]:yarnrc:_files' \
|
||||
'1: :_yarn_commands_scripts' \
|
||||
'*:: :->command_args'
|
||||
|
||||
|
||||
case $state in
|
||||
command_args)
|
||||
case $words[1] in
|
||||
help)
|
||||
_arguments \
|
||||
'1: :_yarn_commands' \
|
||||
;;
|
||||
|
||||
access)
|
||||
_arguments \
|
||||
'1: :(public restricted grant revoke ls-packages ls-collaborators edit)'
|
||||
;;
|
||||
|
||||
add)
|
||||
_arguments \
|
||||
'(-D --dev)'{-D,--dev}'[install packages in devDependencies]' \
|
||||
'(-P --peer)'{-P,--peer}'[install packages in peerDependencies]' \
|
||||
'(-O --optional)'{-O,--optional}'[install packages in optionalDependencies]' \
|
||||
'(-E --exact)'{-E,--exact}'[install packages as exact versions]' \
|
||||
'(-T --tilde)'{-T,--tilde}'[install the most recent release of the packages that have the same minor version]' \
|
||||
'(--ignore-workspace-root-check -W)'{--ignore-workspace-root-check,-W}'[allows a package to be installed at the workspaces root]' \
|
||||
'--audit[checks for known security issues with the installed packages]' \
|
||||
'*:package-name:_yarn_add_files'
|
||||
;;
|
||||
|
||||
audit)
|
||||
_arguments \
|
||||
'--verbose[output verbose message]' \
|
||||
'--json[format Yarn log messages as lines of JSON]' \
|
||||
'--level=[only print advisories with severity greater than or equal to]:level:(info low moderate high critical)' \
|
||||
'--groups=[only audit dependencies from listed groups]:groups:->groups_args'
|
||||
;;
|
||||
|
||||
cache)
|
||||
_arguments \
|
||||
'1: :(list dir clean)' \
|
||||
'*:: :->cache_args'
|
||||
;;
|
||||
|
||||
check)
|
||||
_arguments \
|
||||
'--integrity[Verifies that versions and hashed values of the package contents in package.json]' \
|
||||
'--verify-tree[Recursively verifies that the dependencies in package.json are present in node_modules]'
|
||||
;;
|
||||
|
||||
config)
|
||||
_arguments \
|
||||
'1: :(set get delete list)' \
|
||||
'*:: :->config_args'
|
||||
;;
|
||||
|
||||
global)
|
||||
_arguments \
|
||||
'--prefix=[bin prefix to use to install binaries]' \
|
||||
'1: :_yarn_global_commands' \
|
||||
'*:: :->command_args'
|
||||
;;
|
||||
|
||||
info)
|
||||
_arguments \
|
||||
'1:package:' \
|
||||
'2:field'
|
||||
;;
|
||||
|
||||
init)
|
||||
_arguments \
|
||||
'(-y --yes)'{-y,--yes}'[install packages in devDependencies]'
|
||||
;;
|
||||
|
||||
licenses)
|
||||
_arguments \
|
||||
'1: :(ls generate-disclaimer)' \
|
||||
;;
|
||||
|
||||
link|unlink|outdated)
|
||||
_arguments \
|
||||
'1:package' \
|
||||
;;
|
||||
|
||||
list)
|
||||
_arguments \
|
||||
'--depth=[Limit the depth of the shown dependencies]:depth' \
|
||||
'--pattern=[filter the list of dependencies by the pattern]'
|
||||
;;
|
||||
|
||||
owner)
|
||||
_arguments \
|
||||
'1: :(list add rm)' \
|
||||
'*:: :->owner_args'
|
||||
;;
|
||||
|
||||
pack)
|
||||
_arguments \
|
||||
'(-f --filename)'{-f,--filename}':filename:_files'
|
||||
;;
|
||||
|
||||
publish)
|
||||
_arguments \
|
||||
'--new-version:version:' \
|
||||
'--message:message:' \
|
||||
'--no-git-tag-version' \
|
||||
'--access:access:' \
|
||||
'--tag:tag:' \
|
||||
'1: :_files'
|
||||
;;
|
||||
|
||||
policies)
|
||||
_arguments \
|
||||
'1: :(set-version)'
|
||||
;;
|
||||
|
||||
remove|upgrade)
|
||||
_arguments \
|
||||
'*:package:'
|
||||
;;
|
||||
|
||||
run)
|
||||
if [[ -n $opt_args[--cwd] ]]; then
|
||||
_yarn_run_cwd=$opt_args[--cwd]
|
||||
else
|
||||
_yarn_run_cwd=''
|
||||
fi
|
||||
_arguments \
|
||||
'1: :_yarn_scripts' \
|
||||
'*:: :_default'
|
||||
;;
|
||||
|
||||
tag)
|
||||
_arguments \
|
||||
'1: :(lists add rm)' \
|
||||
'*:: :->tag_args'
|
||||
;;
|
||||
|
||||
team)
|
||||
_arguments \
|
||||
'1: :(create destroy add rm list)' \
|
||||
'*:: :->team_args'
|
||||
;;
|
||||
|
||||
upgrade-interactive)
|
||||
_arguments \
|
||||
'--latest[use the version tagged latest in the registry]'
|
||||
;;
|
||||
|
||||
version)
|
||||
_arguments \
|
||||
'--new-version[create a new version using an interactive session to prompt you]:version:' \
|
||||
'--major[creates a new version by incrementing the major version]' \
|
||||
'--minor[creates a new version by incrementing the minor version]' \
|
||||
'--patch[creates a new version by incrementing the patch version]' \
|
||||
'--premajor[creates a new prerelease version by incrementing the major version]' \
|
||||
'--preminor[creates a new prerelease version by incrementing the minor version]' \
|
||||
'--prepatch[creates a new prerelease version by incrementing the patch version]' \
|
||||
'--prerelease[increments the prerelease version number keeping the main version]' \
|
||||
'--no-git-tag-version[creates a new version without creating a git tag]' \
|
||||
'--no-commit-hooks[bypasses running commit hooks when committing the new version]'
|
||||
;;
|
||||
|
||||
why)
|
||||
_arguments \
|
||||
'1:query:_files'
|
||||
;;
|
||||
|
||||
workspace)
|
||||
_arguments \
|
||||
'1:workspace:_yarn_workspaces' \
|
||||
'*:: :_yarn_global_commands'
|
||||
;;
|
||||
|
||||
workspaces)
|
||||
_arguments \
|
||||
'--json[format Yarn log messages as lines of JSON]' \
|
||||
'1:commands:(info run)'
|
||||
;;
|
||||
|
||||
*)
|
||||
_default
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
case $state in
|
||||
cache_args)
|
||||
if [[ $words[1] == "list" ]]; then
|
||||
_arguments \
|
||||
'--pattern=[print out every cached package that matches the pattern]:pattern:'
|
||||
fi
|
||||
;;
|
||||
config_args)
|
||||
case $words[1] in
|
||||
get|delete)
|
||||
_arguments \
|
||||
'1:key:'
|
||||
;;
|
||||
|
||||
set)
|
||||
_arguments \
|
||||
'(-g --global)'{-g,--global} \
|
||||
'1:key:' \
|
||||
'2:value:'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
groups_args)
|
||||
local dependency_groups=(devDependencies dependencies optionalDependencies peerDependencies bundledDependencies)
|
||||
_values -s ',' 'groups' $dependency_groups
|
||||
;;
|
||||
|
||||
owner_args)
|
||||
case $words[1] in
|
||||
ls)
|
||||
_arguments \
|
||||
'1:package:'
|
||||
;;
|
||||
|
||||
add|rm)
|
||||
_arguments \
|
||||
'1:user:' \
|
||||
'2:package:'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
tag_args)
|
||||
case $words[1] in
|
||||
ls)
|
||||
_arguments \
|
||||
'1:package'
|
||||
;;
|
||||
|
||||
add|rm)
|
||||
_arguments \
|
||||
'1:package:' \
|
||||
'2:tag:'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
team_args)
|
||||
case $words[1] in
|
||||
create|destroy|ls)
|
||||
_arguments \
|
||||
'1:scope\:team:'
|
||||
;;
|
||||
|
||||
add|rm)
|
||||
_arguments \
|
||||
'1:scope\:team:' \
|
||||
'2:user:'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_yarn "$@"
|
||||
|
||||
# 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
|
30
.config/zsh/config/completions/completions/_yt-dlp
Normal file
30
.config/zsh/config/completions/completions/_yt-dlp
Normal file
@ -0,0 +1,30 @@
|
||||
#compdef yt-dlp
|
||||
|
||||
__yt_dlp() {
|
||||
local curcontext="$curcontext" fileopts diropts cur prev
|
||||
typeset -A opt_args
|
||||
fileopts="--download-archive|-a|--batch-file|--load-info-json|--load-info|--cookies|--no-cookies"
|
||||
diropts="--cache-dir"
|
||||
cur=$words[CURRENT]
|
||||
case $cur in
|
||||
:)
|
||||
_arguments '*: :(::ytfavorites ::ytrecommended ::ytsubscriptions ::ytwatchlater ::ythistory)'
|
||||
;;
|
||||
*)
|
||||
prev=$words[CURRENT-1]
|
||||
if [[ ${prev} =~ ${fileopts} ]]; then
|
||||
_path_files
|
||||
elif [[ ${prev} =~ ${diropts} ]]; then
|
||||
_path_files -/
|
||||
elif [[ ${prev} == "--remux-video" ]]; then
|
||||
_arguments '*: :(mp4 mkv)'
|
||||
elif [[ ${prev} == "--recode-video" ]]; then
|
||||
_arguments '*: :(mp4 flv ogg webm mkv)'
|
||||
else
|
||||
_arguments '*: :(--help --version --update --ignore-errors --no-abort-on-error --abort-on-error --dump-user-agent --list-extractors --extractor-descriptions --force-generic-extractor --default-search --ignore-config --config-location --flat-playlist --no-flat-playlist --live-from-start --no-live-from-start --wait-for-video --no-wait-for-video --mark-watched --no-mark-watched --no-colors --compat-options --proxy --socket-timeout --source-address --force-ipv4 --force-ipv6 --geo-verification-proxy --cn-verification-proxy --geo-bypass --no-geo-bypass --geo-bypass-country --geo-bypass-ip-block --playlist-start --playlist-end --playlist-items --match-title --reject-title --min-filesize --max-filesize --date --datebefore --dateafter --min-views --max-views --match-filter --no-match-filter --no-playlist --yes-playlist --age-limit --download-archive --no-download-archive --max-downloads --break-on-existing --break-on-reject --break-per-input --no-break-per-input --skip-playlist-after-errors --include-ads --no-include-ads --concurrent-fragments --limit-rate --throttled-rate --retries --file-access-retries --fragment-retries --skip-unavailable-fragments --abort-on-unavailable-fragment --keep-fragments --no-keep-fragments --buffer-size --resize-buffer --no-resize-buffer --http-chunk-size --test --playlist-reverse --no-playlist-reverse --playlist-random --xattr-set-filesize --hls-prefer-native --hls-prefer-ffmpeg --hls-use-mpegts --no-hls-use-mpegts --downloader --downloader-args --batch-file --no-batch-file --id --paths --output --output-na-placeholder --autonumber-size --autonumber-start --restrict-filenames --no-restrict-filenames --windows-filenames --no-windows-filenames --trim-filenames --no-overwrites --force-overwrites --no-force-overwrites --continue --no-continue --part --no-part --mtime --no-mtime --write-description --no-write-description --write-info-json --no-write-info-json --write-annotations --no-write-annotations --write-playlist-metafiles --no-write-playlist-metafiles --clean-infojson --no-clean-infojson --write-comments --no-write-comments --load-info-json --cookies --no-cookies --cookies-from-browser --no-cookies-from-browser --cache-dir --no-cache-dir --rm-cache-dir --write-thumbnail --no-write-thumbnail --write-all-thumbnails --list-thumbnails --write-link --write-url-link --write-webloc-link --write-desktop-link --quiet --no-warnings --simulate --no-simulate --ignore-no-formats-error --no-ignore-no-formats-error --skip-download --print --get-url --get-title --get-id --get-thumbnail --get-description --get-duration --get-filename --get-format --dump-json --dump-single-json --print-json --force-write-archive --newline --no-progress --progress --console-title --progress-template --verbose --dump-pages --write-pages --youtube-print-sig-code --print-traffic --call-home --no-call-home --encoding --no-check-certificates --prefer-insecure --user-agent --referer --add-header --bidi-workaround --sleep-requests --sleep-interval --max-sleep-interval --sleep-subtitles --format --format-sort --format-sort-force --no-format-sort-force --video-multistreams --no-video-multistreams --audio-multistreams --no-audio-multistreams --all-formats --prefer-free-formats --no-prefer-free-formats --check-formats --check-all-formats --no-check-formats --list-formats --list-formats-as-table --list-formats-old --merge-output-format --allow-unplayable-formats --no-allow-unplayable-formats --write-subs --no-write-subs --write-auto-subs --no-write-auto-subs --all-subs --list-subs --sub-format --sub-langs --username --password --twofactor --netrc --netrc-location --video-password --ap-mso --ap-username --ap-password --ap-list-mso --extract-audio --audio-format --audio-quality --remux-video --recode-video --postprocessor-args --keep-video --no-keep-video --post-overwrites --no-post-overwrites --embed-subs --no-embed-subs --embed-thumbnail --no-embed-thumbnail --embed-metadata --no-embed-metadata --embed-chapters --no-embed-chapters --embed-info-json --no-embed-info-json --metadata-from-title --parse-metadata --replace-in-metadata --xattrs --fixup --prefer-avconv --prefer-ffmpeg --ffmpeg-location --exec --no-exec --exec-before-download --no-exec-before-download --convert-subs --convert-thumbnails --split-chapters --no-split-chapters --remove-chapters --no-remove-chapters --force-keyframes-at-cuts --no-force-keyframes-at-cuts --use-postprocessor --sponsorblock-mark --sponsorblock-remove --sponsorblock-chapter-title --no-sponsorblock --sponsorblock-api --sponskrub --no-sponskrub --sponskrub-cut --no-sponskrub-cut --sponskrub-force --no-sponskrub-force --sponskrub-location --sponskrub-args --extractor-retries --allow-dynamic-mpd --ignore-dynamic-mpd --hls-split-discontinuity --no-hls-split-discontinuity --extractor-args --youtube-include-dash-manifest --youtube-skip-dash-manifest --youtube-include-hls-manifest --youtube-skip-hls-manifest)'
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__yt_dlp
|
@ -0,0 +1,60 @@
|
||||
# Source this file to activate auto completion for zsh using the bash
|
||||
# compatibility helper. Make sure to run `compinit` before, which should be
|
||||
# given usually.
|
||||
#
|
||||
# % source /path/to/zsh_complete.sh
|
||||
#
|
||||
# Typically that would be called somewhere in your .zshrc.
|
||||
#
|
||||
# Note, the overwrite of _bash_complete() is to export COMP_LINE and COMP_POINT
|
||||
# That is only required for zsh <= edab1d3dbe61da7efe5f1ac0e40444b2ec9b9570
|
||||
#
|
||||
# https://github.com/zsh-users/zsh/commit/edab1d3dbe61da7efe5f1ac0e40444b2ec9b9570
|
||||
#
|
||||
# zsh relases prior to that version do not export the required env variables!
|
||||
|
||||
autoload -Uz bashcompinit
|
||||
bashcompinit -i
|
||||
|
||||
_bash_complete() {
|
||||
local ret=1
|
||||
local -a suf matches
|
||||
local -x COMP_POINT COMP_CWORD
|
||||
local -a COMP_WORDS COMPREPLY BASH_VERSINFO
|
||||
local -x COMP_LINE="$words"
|
||||
local -A savejobstates savejobtexts
|
||||
|
||||
(( COMP_POINT = 1 + ${#${(j. .)words[1,CURRENT]}} + $#QIPREFIX + $#IPREFIX + $#PREFIX ))
|
||||
(( COMP_CWORD = CURRENT - 1))
|
||||
COMP_WORDS=( $words )
|
||||
BASH_VERSINFO=( 2 05b 0 1 release )
|
||||
|
||||
savejobstates=( ${(kv)jobstates} )
|
||||
savejobtexts=( ${(kv)jobtexts} )
|
||||
|
||||
[[ ${argv[${argv[(I)nospace]:-0}-1]} = -o ]] && suf=( -S '' )
|
||||
|
||||
matches=( ${(f)"$(compgen $@ -- ${words[CURRENT]})"} )
|
||||
|
||||
if [[ -n $matches ]]; then
|
||||
if [[ ${argv[${argv[(I)filenames]:-0}-1]} = -o ]]; then
|
||||
compset -P '*/' && matches=( ${matches##*/} )
|
||||
compset -S '/*' && matches=( ${matches%%/*} )
|
||||
compadd -Q -f "${suf[@]}" -a matches && ret=0
|
||||
else
|
||||
compadd -Q "${suf[@]}" -a matches && ret=0
|
||||
fi
|
||||
fi
|
||||
|
||||
if (( ret )); then
|
||||
if [[ ${argv[${argv[(I)default]:-0}-1]} = -o ]]; then
|
||||
_default "${suf[@]}" && ret=0
|
||||
elif [[ ${argv[${argv[(I)dirnames]:-0}-1]} = -o ]]; then
|
||||
_directories "${suf[@]}" && ret=0
|
||||
fi
|
||||
fi
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
complete -C aws_completer aws
|
8
.config/zsh/config/completions/init.zsh
Normal file
8
.config/zsh/config/completions/init.zsh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
init() {
|
||||
FPATH="${FPATH}:${BASE_ZSH_CONFIG_DIR}/config/completions/completions"
|
||||
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
}
|
16
.config/zsh/config/init.zsh
Normal file
16
.config/zsh/config/init.zsh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
configure() {
|
||||
autoload -U +X bashcompinit && bashcompinit
|
||||
}
|
||||
|
||||
init() {
|
||||
source ./themes/init.zsh
|
||||
source ./omz/init.zsh
|
||||
source ./programs/init.zsh
|
||||
source ./profile/init.zsh
|
||||
source ./style/init.zsh
|
||||
configure
|
||||
}
|
||||
|
||||
init
|
44
.config/zsh/config/omz/init.zsh
Normal file
44
.config/zsh/config/omz/init.zsh
Normal file
@ -0,0 +1,44 @@
|
||||
OMZ_DIRS="${BASE_ZSH_CONFIG_DIR}/config/omz"
|
||||
|
||||
configure() {
|
||||
plugins=(
|
||||
git
|
||||
zsh-autosuggestions
|
||||
zsh-completions
|
||||
zsh-syntax-highlighting
|
||||
colored-man-pages
|
||||
pip
|
||||
extract
|
||||
fzf-tab
|
||||
autojump
|
||||
aws
|
||||
docker
|
||||
docker-compose
|
||||
nmap
|
||||
npm
|
||||
python
|
||||
zsh-vi-mode
|
||||
zsh-kitty
|
||||
rust
|
||||
dotnet
|
||||
)
|
||||
|
||||
if [[ "${OSTYPE}" = "darwin"* ]]; then
|
||||
plugins +=(
|
||||
macos
|
||||
)
|
||||
fi
|
||||
|
||||
export plugins
|
||||
export ZSH_AUTOSUGGEST_STRATEGY=(history completion)
|
||||
}
|
||||
|
||||
init() {
|
||||
export ZSH="${OMZ_DIRS}/omz/omz/.oh-my-zsh"
|
||||
export ZSH_CUSTOM="${OMZ_DIRS}/"
|
||||
|
||||
configure
|
||||
source "${ZSH}/oh-my-zsh.sh"
|
||||
}
|
||||
|
||||
init
|
1
.config/zsh/config/omz/omz
Submodule
1
.config/zsh/config/omz/omz
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit aa75eeea3348b906f2016be0e44335889e0faed1
|
2
.config/zsh/config/omz/plugins/fzf-tab/.gitattributes
vendored
Normal file
2
.config/zsh/config/omz/plugins/fzf-tab/.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
modules/** linguist-vendored
|
||||
modules/Src/aloxaf/*.c -linguist-vendored
|
42
.config/zsh/config/omz/plugins/fzf-tab/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
42
.config/zsh/config/omz/plugins/fzf-tab/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[BUG]"
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
#### Describe the bug
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
I can make sure:
|
||||
- [ ] I am using the latest version of fzf-tab
|
||||
- [ ] this is the minimal zshrc which can reproduce this bug
|
||||
- [ ] fzf-tab is loaded after `compinit`
|
||||
- [ ] fzf-tab is loaded after plugins which will wrap <kbd>Tab</kbd>, like [junegunn/fzf/completion.zsh](https://github.com/junegunn/fzf/blob/master/shell/completion.zsh)
|
||||
- [ ] fzf-tab is loaded before zsh-autosuggestions, zsh-syntax-highlighting and fast-syntax-highlighting.
|
||||
|
||||
#### To Reproduce
|
||||
Steps to reproduce the behavior:
|
||||
1. Type '...'
|
||||
2. Press <kbd>Tab</kbd>
|
||||
4. See error
|
||||
|
||||
#### Expected behavior
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
#### Screenshots
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
#### Environment:
|
||||
- OS: [e.g. Arch Linux]
|
||||
- zsh version: [e.g. 5.8.1]
|
||||
|
||||
#### Minimal zshrc
|
||||
If applicable, add a minimal zshrc to help us analyze.
|
||||
|
||||
#### Log
|
||||
If applicable, use `C-x .` to trigger completion and provide the log.
|
||||
|
||||
If there are only three lines in your log, please make sure your fzf-tab is loaded with the correct order (see the checklist above).
|
20
.config/zsh/config/omz/plugins/fzf-tab/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.config/zsh/config/omz/plugins/fzf-tab/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[FR]"
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
11
.config/zsh/config/omz/plugins/fzf-tab/.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
11
.config/zsh/config/omz/plugins/fzf-tab/.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
name: Question
|
||||
about: Ask a question about fzf-tab
|
||||
title: "[Q]"
|
||||
labels: question
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe your question**
|
||||
A clear and concise description of your question.
|
36
.config/zsh/config/omz/plugins/fzf-tab/.github/workflows/ci.yaml
vendored
Normal file
36
.config/zsh/config/omz/plugins/fzf-tab/.github/workflows/ci.yaml
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: run test
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: install zsh (ubuntu)
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: sudo apt-get install zsh
|
||||
|
||||
- name: test completion (ubuntu)
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: cd test && zsh -f runtests.zsh fzftab.ztst
|
||||
|
||||
- name: build binary module
|
||||
run: zsh -fc 'source ./fzf-tab.zsh && build-fzf-tab-module'
|
||||
|
||||
- name: test binary module (ubuntu)
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: cd test && zsh -f runtests.zsh fzftab.ztst
|
||||
|
1
.config/zsh/config/omz/plugins/fzf-tab/.gitignore
vendored
Normal file
1
.config/zsh/config/omz/plugins/fzf-tab/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.zwc
|
21
.config/zsh/config/omz/plugins/fzf-tab/LICENSE
Normal file
21
.config/zsh/config/omz/plugins/fzf-tab/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2021 Aloxaf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
138
.config/zsh/config/omz/plugins/fzf-tab/README.md
Normal file
138
.config/zsh/config/omz/plugins/fzf-tab/README.md
Normal file
@ -0,0 +1,138 @@
|
||||
# fzf-tab
|
||||
|
||||
[![CI](https://github.com/Aloxaf/fzf-tab/workflows/ci/badge.svg)](https://github.com/Aloxaf/fzf-tab/actions?query=workflow%3Aci)
|
||||
[![GitHub license](https://img.shields.io/github/license/Aloxaf/fzf-tab)](https://github.com/Aloxaf/fzf-tab/blob/master/LICENSE)
|
||||
|
||||
Replace zsh's default completion selection menu with fzf!
|
||||
|
||||
[![asciicast](https://asciinema.org/a/293849.svg)](https://asciinema.org/a/293849)
|
||||
|
||||
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
|
||||
**Table of Contents**
|
||||
|
||||
- [fzf-tab](#fzf-tab)
|
||||
- [Install](#install)
|
||||
- [Manual](#manual)
|
||||
- [Antigen](#antigen)
|
||||
- [Zinit](#zinit)
|
||||
- [Oh-My-Zsh](#oh-my-zsh)
|
||||
- [Prezto](#prezto)
|
||||
- [Usage](#usage)
|
||||
- [Configure](#configure)
|
||||
- [Binary module](#binary-module)
|
||||
- [Difference from other plugins](#difference-from-other-plugins)
|
||||
- [Compatibility with other plugins](#compatibility-with-other-plugins)
|
||||
- [Related projects](#related-projects)
|
||||
|
||||
<!-- markdown-toc end -->
|
||||
|
||||
# Install
|
||||
|
||||
**NOTE: fzf-tab needs to be loaded after `compinit`, but before plugins which will wrap widgets, such as [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) or [fast-syntax-highlighting](https://github.com/zdharma-continuum/fast-syntax-highlighting)!!**
|
||||
|
||||
### Manual
|
||||
|
||||
First, clone this repository.
|
||||
|
||||
```zsh
|
||||
git clone https://github.com/Aloxaf/fzf-tab ~/somewhere
|
||||
```
|
||||
|
||||
Then add the following line to your `~/.zshrc`.
|
||||
|
||||
```zsh
|
||||
source ~/somewhere/fzf-tab.plugin.zsh
|
||||
```
|
||||
|
||||
### Antigen
|
||||
|
||||
```zsh
|
||||
antigen bundle Aloxaf/fzf-tab
|
||||
```
|
||||
|
||||
### Zinit
|
||||
|
||||
```zsh
|
||||
zinit light Aloxaf/fzf-tab
|
||||
```
|
||||
|
||||
### Oh-My-Zsh
|
||||
|
||||
Clone this repository to your custom directory and then add `fzf-tab` to your plugin list.
|
||||
|
||||
```zsh
|
||||
git clone https://github.com/Aloxaf/fzf-tab ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fzf-tab
|
||||
```
|
||||
|
||||
### Prezto
|
||||
|
||||
Clone this repository to your contrib directory and then add `fzf-tab` to your module list in `.zpreztorc`.
|
||||
|
||||
```zsh
|
||||
git clone https://github.com/Aloxaf/fzf-tab $ZPREZTODIR/contrib/fzf-tab
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
Just press <kbd>Tab</kbd> as usual~
|
||||
|
||||
Available keybindings:
|
||||
|
||||
- <kbd>Ctrl</kdb>+<kdb>Space</kbd>: select multiple results, can be configured by `fzf-bindings` tag
|
||||
|
||||
- <kbd>F1</kbd>/<kbd>F2</kbd>: switch between groups, can be configured by `switch-group` tag
|
||||
|
||||
- <kbd>/</kbd>: trigger continuous completion (useful when completing a deep path), can be configured by `continuous-trigger` tag
|
||||
|
||||
Available commands:
|
||||
|
||||
- `disable-fzf-tab`: disable fzf-tab and fallback to compsys
|
||||
|
||||
- `enable-fzf-tab`: enable fzf-tab
|
||||
|
||||
- `toggle-fzf-tab`: toggle the state of fzf-tab. This is also a zle widget.
|
||||
|
||||
## Configure
|
||||
|
||||
A common configuration is:
|
||||
|
||||
```zsh
|
||||
# disable sort when completing `git checkout`
|
||||
zstyle ':completion:*:git-checkout:*' sort false
|
||||
# set descriptions format to enable group support
|
||||
zstyle ':completion:*:descriptions' format '[%d]'
|
||||
# set list-colors to enable filename colorizing
|
||||
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
||||
# preview directory's content with exa when completing cd
|
||||
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
|
||||
# switch group using `,` and `.`
|
||||
zstyle ':fzf-tab:*' switch-group ',' '.'
|
||||
```
|
||||
|
||||
For more information, please see [Wiki#Configuration](https://github.com/Aloxaf/fzf-tab/wiki/Configuration).
|
||||
|
||||
## Binary module
|
||||
|
||||
By default, fzf-tab uses [zsh-ls-colors](https://github.com/xPMo/zsh-ls-colors) to parse and apply ZLS_COLORS if you have set the `list-colors` tag.
|
||||
|
||||
However, it is a pure zsh script and is slow if you have too many files to colorize.
|
||||
fzf-tab is shipped with a binary module to speed up this process. You can build it with `build-fzf-tab-module`, then it will be enabled automatically.
|
||||
|
||||
# Difference from other plugins
|
||||
|
||||
fzf-tab doesn't do "complete", it just shows you the results of the default completion system.
|
||||
|
||||
So it works EVERYWHERE (variables, function names, directory stack, in-word completion, etc.).
|
||||
And most of your configuration for default completion system is still valid.
|
||||
|
||||
# Compatibility with other plugins
|
||||
|
||||
Some plugins may also bind "^I" to their custom widget, like [fzf/shell/completion.zsh](https://github.com/junegunn/fzf/blob/master/shell/completion.zsh) or [ohmyzsh/lib/completion.zsh](https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/completion.zsh#L61-L73).
|
||||
|
||||
By default, fzf-tab will call the widget previously bound to "^I" to get the completion list. So there is no problem in most cases, unless fzf-tab is initialized before a plugin which doesn't handle the previous binding properly.
|
||||
|
||||
So if you find your fzf-tab doesn't work properly, **please make sure it is the last plugin to bind "^I"** (If you don't know what I mean, just put it to the end of your plugin list).
|
||||
|
||||
# Related projects
|
||||
|
||||
- https://github.com/lincheney/fzf-tab-completion (fzf tab completion for zsh, bash and GNU readline apps)
|
@ -0,0 +1,3 @@
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
source "${0:A:h}/fzf-tab.zsh"
|
399
.config/zsh/config/omz/plugins/fzf-tab/fzf-tab.zsh
Normal file
399
.config/zsh/config/omz/plugins/fzf-tab/fzf-tab.zsh
Normal file
@ -0,0 +1,399 @@
|
||||
# temporarily change options
|
||||
'builtin' 'local' '-a' '_ftb_opts'
|
||||
[[ ! -o 'aliases' ]] || _ftb_opts+=('aliases')
|
||||
[[ ! -o 'sh_glob' ]] || _ftb_opts+=('sh_glob')
|
||||
[[ ! -o 'no_brace_expand' ]] || _ftb_opts+=('no_brace_expand')
|
||||
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
|
||||
|
||||
# thanks Valodim/zsh-capture-completion
|
||||
-ftb-compadd() {
|
||||
# parse all options
|
||||
local -A apre hpre dscrs _oad
|
||||
local -a isfile _opts __ expl
|
||||
zparseopts -E -a _opts P:=apre p:=hpre d:=dscrs X+:=expl O:=_oad A:=_oad D:=_oad f=isfile \
|
||||
i: S: s: I: x: r: R: W: F: M+: E: q e Q n U C \
|
||||
J:=__ V:=__ a=__ l=__ k=__ o=__ 1=__ 2=__
|
||||
|
||||
# just delegate and leave if any of -O, -A or -D are given or fzf-tab is not enabled
|
||||
if (( $#_oad != 0 || ! IN_FZF_TAB )); then
|
||||
builtin compadd "$@"
|
||||
return
|
||||
fi
|
||||
|
||||
# store matches in $__hits and descriptions in $__dscr
|
||||
local -a __hits __dscr
|
||||
if (( $#dscrs == 1 )); then
|
||||
__dscr=( "${(@P)${(v)dscrs}}" )
|
||||
fi
|
||||
builtin compadd -A __hits -D __dscr "$@"
|
||||
local ret=$?
|
||||
if (( $#__hits == 0 )); then
|
||||
return $ret
|
||||
fi
|
||||
|
||||
# store $curcontext for furthur usage
|
||||
_ftb_curcontext=${curcontext#:}
|
||||
|
||||
# only store the fist `-X`
|
||||
expl=$expl[2]
|
||||
|
||||
# keep order of group description
|
||||
[[ -n $expl ]] && _ftb_groups+=$expl
|
||||
|
||||
# store these values in _ftb_compcap
|
||||
local -a keys=(apre hpre PREFIX SUFFIX IPREFIX ISUFFIX)
|
||||
local key expanded __tmp_value=$'<\0>' # placeholder
|
||||
for key in $keys; do
|
||||
expanded=${(P)key}
|
||||
if [[ -n $expanded ]]; then
|
||||
__tmp_value+=$'\0'$key$'\0'$expanded
|
||||
fi
|
||||
done
|
||||
if [[ -n $expl ]]; then
|
||||
# store group index
|
||||
__tmp_value+=$'\0group\0'$_ftb_groups[(ie)$expl]
|
||||
fi
|
||||
if [[ -n $isfile ]]; then
|
||||
# NOTE: need a extra ${} here or ~ expansion won't work
|
||||
__tmp_value+=$'\0realdir\0'${${(Qe)~${:-$IPREFIX$hpre}}}
|
||||
fi
|
||||
_opts+=("${(@kv)apre}" "${(@kv)hpre}" $isfile)
|
||||
__tmp_value+=$'\0args\0'${(pj:\1:)_opts}
|
||||
|
||||
if (( $+builtins[fzf-tab-compcap-generate] )); then
|
||||
fzf-tab-compcap-generate __hits __dscr __tmp_value
|
||||
else
|
||||
# dscr - the string to show to users
|
||||
# word - the string to be inserted
|
||||
local dscr word i
|
||||
for i in {1..$#__hits}; do
|
||||
word=$__hits[i] dscr=$__dscr[i]
|
||||
if [[ -n $dscr ]]; then
|
||||
dscr=${dscr//$'\n'}
|
||||
elif [[ -n $word ]]; then
|
||||
dscr=$word
|
||||
fi
|
||||
_ftb_compcap+=$dscr$'\2'$__tmp_value$'\0word\0'$word
|
||||
done
|
||||
fi
|
||||
|
||||
# tell zsh that the match is successful
|
||||
builtin compadd -U -qS '' -R -ftb-remove-space ''
|
||||
}
|
||||
|
||||
# when insert multi results, a whitespace will be added to each result
|
||||
# remove left space of our fake result because I can't remove right space
|
||||
# FIXME: what if the left char is not whitespace: `echo $widgets[\t`
|
||||
-ftb-remove-space() {
|
||||
[[ $LBUFFER[-1] == ' ' ]] && LBUFFER[-1]=''
|
||||
}
|
||||
|
||||
-ftb-zstyle() {
|
||||
zstyle $1 ":fzf-tab:$_ftb_curcontext" ${@:2}
|
||||
}
|
||||
|
||||
-ftb-complete() {
|
||||
local -a _ftb_compcap
|
||||
local -Ua _ftb_groups
|
||||
local choice choices _ftb_curcontext continuous_trigger print_query accept_line bs=$'\2' nul=$'\0'
|
||||
local ret=0
|
||||
|
||||
# must run with user options; don't move `emulate -L zsh` above this line
|
||||
(( $+builtins[fzf-tab-compcap-generate] )) && fzf-tab-compcap-generate -i
|
||||
COLUMNS=500 _ftb__main_complete "$@" || ret=$?
|
||||
(( $+builtins[fzf-tab-compcap-generate] )) && fzf-tab-compcap-generate -o
|
||||
|
||||
emulate -L zsh -o extended_glob
|
||||
|
||||
local _ftb_query _ftb_complist=() _ftb_headers=() command opts
|
||||
-ftb-generate-complist # sets `_ftb_complist`
|
||||
|
||||
-ftb-zstyle -s continuous-trigger continuous_trigger || {
|
||||
[[ $OSTYPE == msys ]] && continuous_trigger=// || continuous_trigger=/
|
||||
}
|
||||
|
||||
case $#_ftb_complist in
|
||||
0) return 1;;
|
||||
1)
|
||||
choices=("EXPECT_KEY" "${_ftb_compcap[1]%$bs*}")
|
||||
if (( _ftb_continue_last )); then
|
||||
choices[1]=$continuous_trigger
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
-ftb-generate-query # sets `_ftb_query`
|
||||
-ftb-generate-header # sets `_ftb_headers`
|
||||
-ftb-zstyle -s print-query print_query || print_query=alt-enter
|
||||
-ftb-zstyle -s accept-line accept_line
|
||||
|
||||
choices=("${(@f)"$(builtin print -rl -- $_ftb_headers $_ftb_complist | -ftb-fzf)"}")
|
||||
ret=$?
|
||||
# choices=(query_string expect_key returned_word)
|
||||
|
||||
# insert query string directly
|
||||
if [[ $choices[2] == $print_query ]] || [[ -n $choices[1] && $#choices == 1 ]] ; then
|
||||
local -A v=("${(@0)${_ftb_compcap[1]}}")
|
||||
local -a args=("${(@ps:\1:)v[args]}")
|
||||
[[ -z $args[1] ]] && args=() # don't pass an empty string
|
||||
IPREFIX=$v[IPREFIX] PREFIX=$v[PREFIX] SUFFIX=$v[SUFFIX] ISUFFIX=$v[ISUFFIX]
|
||||
# NOTE: should I use `-U` here?, ../f\tabcd -> ../abcd
|
||||
builtin compadd "${args[@]:--Q}" -Q -- $choices[1]
|
||||
|
||||
compstate[list]=
|
||||
compstate[insert]=
|
||||
if (( $#choices[1] > 0 )); then
|
||||
compstate[insert]='2'
|
||||
[[ $RBUFFER == ' '* ]] || compstate[insert]+=' '
|
||||
fi
|
||||
return $ret
|
||||
fi
|
||||
choices[1]=()
|
||||
|
||||
choices=("${(@)${(@)choices%$nul*}#*$nul}")
|
||||
|
||||
unset CTXT
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -n $choices[1] && $choices[1] == $continuous_trigger ]]; then
|
||||
typeset -gi _ftb_continue=1
|
||||
typeset -gi _ftb_continue_last=1
|
||||
fi
|
||||
|
||||
if [[ -n $choices[1] && $choices[1] == $accept_line ]]; then
|
||||
typeset -gi _ftb_accept=1
|
||||
fi
|
||||
choices[1]=()
|
||||
|
||||
for choice in "$choices[@]"; do
|
||||
local -A v=("${(@0)${_ftb_compcap[(r)${(b)choice}$bs*]#*$bs}}")
|
||||
local -a args=("${(@ps:\1:)v[args]}")
|
||||
[[ -z $args[1] ]] && args=() # don't pass an empty string
|
||||
IPREFIX=$v[IPREFIX] PREFIX=$v[PREFIX] SUFFIX=$v[SUFFIX] ISUFFIX=$v[ISUFFIX]
|
||||
builtin compadd "${args[@]:--Q}" -Q -- "$v[word]"
|
||||
done
|
||||
|
||||
compstate[list]=
|
||||
compstate[insert]=
|
||||
if (( $#choices == 1 )); then
|
||||
compstate[insert]='2'
|
||||
[[ $RBUFFER == ' '* ]] || compstate[insert]+=' '
|
||||
elif (( $#choices > 1 )); then
|
||||
compstate[insert]='all'
|
||||
fi
|
||||
return $ret
|
||||
}
|
||||
|
||||
fzf-tab-debug() {
|
||||
(( $+_ftb_debug_cnt )) || typeset -gi _ftb_debug_cnt
|
||||
local tmp=${TMPPREFIX:-/tmp/zsh}-$$-fzf-tab-$(( ++_ftb_debug_cnt )).log
|
||||
local -i debug_fd=-1 IN_FZF_TAB=1
|
||||
{
|
||||
exec {debug_fd}>&2 2>| $tmp
|
||||
local -a debug_indent; debug_indent=( '%'{3..20}'(e. .)' )
|
||||
local PROMPT4 PS4="${(j::)debug_indent}+%N:%i> "
|
||||
setopt xtrace
|
||||
: $ZSH_NAME $ZSH_VERSION
|
||||
zle .fzf-tab-orig-$_ftb_orig_widget
|
||||
unsetopt xtrace
|
||||
if (( debug_fd != -1 )); then
|
||||
zle -M "fzf-tab-debug: Trace output left in $tmp"
|
||||
fi
|
||||
} always {
|
||||
(( debug_fd != -1 )) && exec 2>&$debug_fd {debug_fd}>&-
|
||||
}
|
||||
}
|
||||
|
||||
fzf-tab-complete() {
|
||||
# this name must be ugly to avoid clashes
|
||||
local -i _ftb_continue=1 _ftb_continue_last=0 _ftb_accept=0 ret=0
|
||||
# hide the cursor until finishing completion, so that users won't see cursor up and down
|
||||
# NOTE: MacOS Terminal doesn't support civis & cnorm
|
||||
echoti civis >/dev/tty 2>/dev/null
|
||||
while (( _ftb_continue )); do
|
||||
_ftb_continue=0
|
||||
local IN_FZF_TAB=1
|
||||
{
|
||||
zle .fzf-tab-orig-$_ftb_orig_widget
|
||||
ret=$?
|
||||
} always {
|
||||
IN_FZF_TAB=0
|
||||
}
|
||||
if (( _ftb_continue )); then
|
||||
zle .split-undo
|
||||
zle .reset-prompt
|
||||
zle -R
|
||||
zle fzf-tab-dummy
|
||||
fi
|
||||
done
|
||||
echoti cnorm >/dev/tty 2>/dev/null
|
||||
zle .redisplay
|
||||
(( _ftb_accept )) && zle .accept-line
|
||||
return $ret
|
||||
}
|
||||
|
||||
# this function does nothing, it is used to be wrapped by other plugins like f-sy-h.
|
||||
# this make it possible to call the wrapper function without causing any other side effects.
|
||||
fzf-tab-dummy() { }
|
||||
|
||||
zle -N fzf-tab-debug
|
||||
zle -N fzf-tab-complete
|
||||
zle -N fzf-tab-dummy
|
||||
|
||||
disable-fzf-tab() {
|
||||
emulate -L zsh -o extended_glob
|
||||
(( $+_ftb_orig_widget )) || return 0
|
||||
|
||||
bindkey '^I' $_ftb_orig_widget
|
||||
case $_ftb_orig_list_grouped in
|
||||
0) zstyle ':completion:*' list-grouped false ;;
|
||||
1) zstyle ':completion:*' list-grouped true ;;
|
||||
2) zstyle -d ':completion:*' list-grouped ;;
|
||||
esac
|
||||
unset _ftb_orig_widget _ftb_orig_list_groupded
|
||||
|
||||
# unhook compadd so that _approximate can work properply
|
||||
unfunction compadd 2>/dev/null
|
||||
|
||||
functions[_main_complete]=$functions[_ftb__main_complete]
|
||||
functions[_approximate]=$functions[_ftb__approximate]
|
||||
|
||||
# Don't remove .fzf-tab-orig-$_ftb_orig_widget as we won't be able to reliably
|
||||
# create it if enable-fzf-tab is called again.
|
||||
}
|
||||
|
||||
enable-fzf-tab() {
|
||||
emulate -L zsh -o extended_glob
|
||||
(( ! $+_ftb_orig_widget )) || disable-fzf-tab
|
||||
|
||||
typeset -g _ftb_orig_widget="${${$(builtin bindkey '^I')##* }:-expand-or-complete}"
|
||||
if (( ! $+widgets[.fzf-tab-orig-$_ftb_orig_widget] )); then
|
||||
# Widgets that get replaced by compinit.
|
||||
local compinit_widgets=(
|
||||
complete-word
|
||||
delete-char-or-list
|
||||
expand-or-complete
|
||||
expand-or-complete-prefix
|
||||
list-choices
|
||||
menu-complete
|
||||
menu-expand-or-complete
|
||||
reverse-menu-complete
|
||||
)
|
||||
# Note: We prefix the name of the widget with '.' so that it doesn't get wrapped.
|
||||
if [[ $widgets[$_ftb_orig_widget] == builtin &&
|
||||
$compinit_widgets[(Ie)$_ftb_orig_widget] != 0 ]]; then
|
||||
# We are initializing before compinit and being asked to fall back to a completion
|
||||
# widget that isn't defined yet. Create our own copy of the widget ahead of time.
|
||||
zle -C .fzf-tab-orig-$_ftb_orig_widget .$_ftb_orig_widget _main_complete
|
||||
else
|
||||
# Copy the widget before it's wrapped by zsh-autosuggestions and zsh-syntax-highlighting.
|
||||
zle -A $_ftb_orig_widget .fzf-tab-orig-$_ftb_orig_widget
|
||||
fi
|
||||
fi
|
||||
|
||||
zstyle -t ':completion:*' list-grouped false
|
||||
typeset -g _ftb_orig_list_grouped=$?
|
||||
|
||||
zstyle ':completion:*' list-grouped false
|
||||
bindkey -M emacs '^I' fzf-tab-complete
|
||||
bindkey -M viins '^I' fzf-tab-complete
|
||||
bindkey -M emacs '^X.' fzf-tab-debug
|
||||
bindkey -M viins '^X.' fzf-tab-debug
|
||||
|
||||
# make sure we can copy them
|
||||
autoload +X -Uz _main_complete _approximate
|
||||
|
||||
# hook compadd
|
||||
functions[compadd]=$functions[-ftb-compadd]
|
||||
|
||||
# hook _main_complete to trigger fzf-tab
|
||||
functions[_ftb__main_complete]=$functions[_main_complete]
|
||||
function _main_complete() { -ftb-complete "$@" }
|
||||
|
||||
# TODO: This is not a full support, see #47
|
||||
# _approximate will also hook compadd
|
||||
# let it call -ftb-compadd instead of builtin compadd so that fzf-tab can capture result
|
||||
# make sure _approximate has been loaded.
|
||||
functions[_ftb__approximate]=$functions[_approximate]
|
||||
function _approximate() {
|
||||
# if not called by fzf-tab, don't do anything with compadd
|
||||
(( ! IN_FZF_TAB )) || unfunction compadd
|
||||
_ftb__approximate
|
||||
(( ! IN_FZF_TAB )) || functions[compadd]=$functions[-ftb-compadd]
|
||||
}
|
||||
}
|
||||
|
||||
toggle-fzf-tab() {
|
||||
emulate -L zsh -o extended_glob
|
||||
if (( $+_ftb_orig_widget )); then
|
||||
disable-fzf-tab
|
||||
else
|
||||
enable-fzf-tab
|
||||
fi
|
||||
}
|
||||
|
||||
build-fzf-tab-module() {
|
||||
local MACOS
|
||||
if [[ ${OSTYPE} == darwin* ]]; then
|
||||
MACOS=true
|
||||
fi
|
||||
pushd $FZF_TAB_HOME/modules
|
||||
CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O2" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp ${MACOS:+DL_EXT=bundle}
|
||||
make -j$(nproc)
|
||||
popd
|
||||
}
|
||||
|
||||
zmodload zsh/zutil
|
||||
zmodload zsh/mapfile
|
||||
zmodload -F zsh/stat b:zstat
|
||||
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
FZF_TAB_HOME="${0:A:h}"
|
||||
|
||||
source "$FZF_TAB_HOME"/lib/zsh-ls-colors/ls-colors.zsh fzf-tab-lscolors
|
||||
|
||||
typeset -ga _ftb_group_colors=(
|
||||
$'\x1b[94m' $'\x1b[32m' $'\x1b[33m' $'\x1b[35m' $'\x1b[31m' $'\x1b[38;5;27m' $'\x1b[36m'
|
||||
$'\x1b[38;5;100m' $'\x1b[38;5;98m' $'\x1b[91m' $'\x1b[38;5;80m' $'\x1b[92m'
|
||||
$'\x1b[38;5;214m' $'\x1b[38;5;165m' $'\x1b[38;5;124m' $'\x1b[38;5;120m'
|
||||
)
|
||||
|
||||
# init
|
||||
() {
|
||||
emulate -L zsh -o extended_glob
|
||||
|
||||
fpath+=($FZF_TAB_HOME/lib)
|
||||
|
||||
autoload -Uz -- $FZF_TAB_HOME/lib/-#ftb*(:t)
|
||||
|
||||
if (( $+FZF_TAB_COMMAND || $+FZF_TAB_OPTS || $+FZF_TAB_QUERY || $+FZF_TAB_SINGLE_GROUP || $+fzf_tab_preview_init )) \
|
||||
|| zstyle -m ":fzf-tab:*" command '*' \
|
||||
|| zstyle -m ":fzf-tab:*" extra-opts '*'; then
|
||||
print -P "%F{red}%B[fzf-tab] Sorry, your configuration is not supported anymore\n" \
|
||||
"See https://github.com/Aloxaf/fzf-tab/pull/132 for more information%f%b"
|
||||
fi
|
||||
|
||||
if [[ -n $FZF_TAB_HOME/modules/Src/aloxaf/fzftab.(so|bundle)(#qN) ]]; then
|
||||
module_path+=("$FZF_TAB_HOME/modules/Src")
|
||||
zmodload aloxaf/fzftab
|
||||
|
||||
if [[ $FZF_TAB_MODULE_VERSION != "0.2.2" ]]; then
|
||||
zmodload -u aloxaf/fzftab
|
||||
local rebuild
|
||||
print -Pn "%F{yellow}fzftab module needs to be rebuild, rebuild now?[Y/n]:%f"
|
||||
read -q rebuild
|
||||
if [[ $rebuild == y ]]; then
|
||||
build-fzf-tab-module
|
||||
zmodload aloxaf/fzftab
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
enable-fzf-tab
|
||||
zle -N toggle-fzf-tab
|
||||
|
||||
# restore options
|
||||
(( ${#_ftb_opts} )) && setopt ${_ftb_opts[@]}
|
||||
'builtin' 'unset' '_ftb_opts'
|
34
.config/zsh/config/omz/plugins/fzf-tab/lib/-ftb-colorize
Normal file
34
.config/zsh/config/omz/plugins/fzf-tab/lib/-ftb-colorize
Normal file
@ -0,0 +1,34 @@
|
||||
#!/hint/zsh
|
||||
emulate -L zsh -o cbases -o octalzeroes
|
||||
|
||||
local REPLY
|
||||
local -a reply stat lstat
|
||||
|
||||
# fzf-tab-lscolors::match-by $1 lstat follow
|
||||
zstat -A lstat -L -- $1
|
||||
# follow symlink
|
||||
(( lstat[3] & 0170000 )) && zstat -A stat -- $1 2>/dev/null
|
||||
|
||||
fzf-tab-lscolors::from-mode "$1" "$lstat[3]" $stat[3]
|
||||
# fall back to name
|
||||
[[ -z $REPLY ]] && fzf-tab-lscolors::from-name $1
|
||||
|
||||
# If this is a symlink
|
||||
if [[ -n $lstat[14] ]]; then
|
||||
local sym_color=$REPLY
|
||||
local rsv_color=$REPLY
|
||||
local rsv=$lstat[14]
|
||||
# If this is not a broken symlink
|
||||
if [[ -e $rsv ]]; then
|
||||
# fzf-tab-lscolors::match-by $rsv stat
|
||||
zstat -A stat -- $rsv
|
||||
fzf-tab-lscolors::from-mode $rsv $stat[3]
|
||||
# fall back to name
|
||||
[[ -z $REPLY ]] && fzf-tab-lscolors::from-name $rsv
|
||||
rsv_color=$REPLY
|
||||
fi
|
||||
dpre=$'\033[0m\033['$sym_color'm'
|
||||
dsuf+=$'\033[0m -> \033['$rsv_color'm'$rsv
|
||||
else
|
||||
dpre=$'\033[0m\033['$REPLY'm'
|
||||
fi
|
102
.config/zsh/config/omz/plugins/fzf-tab/lib/-ftb-fzf
Executable file
102
.config/zsh/config/omz/plugins/fzf-tab/lib/-ftb-fzf
Executable file
@ -0,0 +1,102 @@
|
||||
#!/hint/zsh
|
||||
|
||||
local tmp_dir=${TMPPREFIX:-/tmp/zsh}-fzf-tab-$USER
|
||||
[[ -d $tmp_dir ]] || command mkdir $tmp_dir
|
||||
|
||||
local ftb_preview_init="
|
||||
zmodload zsh/mapfile
|
||||
local -a _ftb_compcap=(\"\${(@f)mapfile[$tmp_dir/compcap.$$]}\")
|
||||
local -a _ftb_groups=(\"\${(@f)mapfile[$tmp_dir/groups.$$]}\")
|
||||
local bs=\$'\2'
|
||||
# get descriptoin
|
||||
export desc=\${\${\"\$(<{f})\"%\$'\0'*}#*\$'\0'}
|
||||
# get ctxt for current completion
|
||||
local -A ctxt=(\"\${(@0)\${_ftb_compcap[(r)\${(b)desc}\$bs*]#*\$bs}}\")
|
||||
# get group
|
||||
if (( \$+ctxt[group] )); then
|
||||
export group=\$_ftb_groups[\$ctxt[group]]
|
||||
fi
|
||||
# get original word
|
||||
export word=\${(Q)ctxt[word]}
|
||||
# get real path if it is file
|
||||
if (( \$+ctxt[realdir] )); then
|
||||
export realpath=\${ctxt[realdir]}\$word
|
||||
fi
|
||||
"
|
||||
local binds=tab:down,btab:up,change:top,ctrl-space:toggle
|
||||
local fzf_command fzf_flags fzf_preview debug_command tmp switch_group fzf_pad
|
||||
local ret=0
|
||||
|
||||
-ftb-zstyle -s fzf-command fzf_command || fzf_command=fzf
|
||||
-ftb-zstyle -a fzf-bindings tmp && binds+=,${(j:,:)tmp}
|
||||
-ftb-zstyle -a fzf-flags fzf_flags
|
||||
-ftb-zstyle -s fzf-preview fzf_preview
|
||||
-ftb-zstyle -a switch-group switch_group || switch_group=(F1 F2)
|
||||
-ftb-zstyle -s fzf-pad fzf_pad || fzf_pad=2
|
||||
|
||||
-ftb-zstyle -a debug-command debug_command && {
|
||||
${(eX)debug_command} $fzf_flags
|
||||
return
|
||||
}
|
||||
|
||||
print -rl -- $_ftb_compcap > $tmp_dir/compcap.$$
|
||||
print -rl -- $_ftb_groups > $tmp_dir/groups.$$
|
||||
print -r -- ${ftb_preview_init/{f}/\$1} > $tmp_dir/ftb_preview_init.$$
|
||||
|
||||
binds=${binds//{_FTB_INIT_}/. $tmp_dir/ftb_preview_init.$$ {f} $'\n'}
|
||||
|
||||
local -i header_lines=$#_ftb_headers
|
||||
local -i lines=$(( $#_ftb_compcap + fzf_pad + header_lines ))
|
||||
local reload_command="$commands[zsh] -f $FZF_TAB_HOME/lib/ftb-switch-group $$ $header_lines $tmp_dir"
|
||||
|
||||
# detect if we will use tmux popup
|
||||
local use_tmux_popup=0
|
||||
if [[ $fzf_command == "ftb-tmux-popup" ]]; then
|
||||
use_tmux_popup=1
|
||||
fi
|
||||
|
||||
if (( ! use_tmux_popup )); then
|
||||
# fzf will cause the current line to refresh, so move the cursor down.
|
||||
echoti cud1 >/dev/tty
|
||||
# reset cursor before call fzf
|
||||
echoti cnorm >/dev/tty 2>/dev/null
|
||||
fi
|
||||
|
||||
cat > $tmp_dir/completions.$$
|
||||
|
||||
local dd='gdd'
|
||||
if (( ${+commands[$dd]} == 0 )) ; then
|
||||
dd='dd'
|
||||
fi
|
||||
if (( ${+commands[$dd]} == 0 )) ; then
|
||||
dd='true' # nop if dd is not installed
|
||||
fi
|
||||
|
||||
_ftb_query="${_ftb_query}$(command "$dd" bs=1G count=1 status=none iflag=nonblock < /dev/tty 2>/dev/null)" || true
|
||||
|
||||
$fzf_command \
|
||||
--ansi \
|
||||
--bind=$binds \
|
||||
--bind="${switch_group[1]}:reload($reload_command -1),${switch_group[2]}:reload($reload_command 1)" \
|
||||
--color=hl:$(( header_lines == 0 ? 188 : 255 )) \
|
||||
--cycle \
|
||||
--delimiter='\x00' \
|
||||
--expect=$continuous_trigger,$print_query,$accept_line \
|
||||
--header-lines=$header_lines \
|
||||
--height=${FZF_TMUX_HEIGHT:=$(( lines > LINES / 3 * 2 ? LINES / 3 * 2 : lines ))} \
|
||||
--layout=reverse \
|
||||
--multi \
|
||||
--nth=2,3 \
|
||||
--print-query \
|
||||
--query=$_ftb_query \
|
||||
--tiebreak=begin \
|
||||
${fzf_preview:+--preview=$ftb_preview_init$fzf_preview} \
|
||||
$fzf_flags < $tmp_dir/completions.$$ || ret=$?
|
||||
|
||||
if (( ! use_tmux_popup )); then
|
||||
echoti civis >/dev/tty 2>/dev/null
|
||||
echoti cuu1 >/dev/tty
|
||||
fi
|
||||
|
||||
command rm $tmp_dir/*.$$ 2>/dev/null
|
||||
return $ret
|
@ -0,0 +1,113 @@
|
||||
#!/hint/zsh
|
||||
|
||||
local dsuf dpre k _v filepath first_word show_group default_color prefix bs=$'\b'
|
||||
local -a list_colors group_colors tcandidates reply match mbegin mend
|
||||
local -i same_word=1 colorful=0
|
||||
local -Ua duplicate_groups=()
|
||||
local -A word_map=()
|
||||
|
||||
(( $#_ftb_compcap == 0 )) && return
|
||||
|
||||
-ftb-zstyle -s show-group show_group || show_group=full
|
||||
-ftb-zstyle -s default-color default_color || default_color=$'\x1b[37m'
|
||||
-ftb-zstyle -s prefix prefix || {
|
||||
zstyle -m ':completion:*:descriptions' format '*' && prefix='·'
|
||||
}
|
||||
-ftb-zstyle -a group-colors group_colors || group_colors=($_ftb_group_colors)
|
||||
zstyle -a ":completion:$_ftb_curcontext" list-colors list_colors
|
||||
|
||||
# init colorize
|
||||
if (( $+builtins[fzf-tab-candidates-generate] )); then
|
||||
fzf-tab-candidates-generate -i list_colors
|
||||
else
|
||||
local -A namecolors=(${(@s:=:)${(@s.:.)list_colors}:#[[:alpha:]][[:alpha:]]=*})
|
||||
local -A modecolors=(${(@Ms:=:)${(@s.:.)list_colors}:#[[:alpha:]][[:alpha:]]=*})
|
||||
(( $#namecolors == 0 && $#modecolors == 0 )) && list_colors=()
|
||||
fi
|
||||
|
||||
if (( $#_ftb_groups == 1 )); then
|
||||
-ftb-zstyle -m single-group prefix || prefix=''
|
||||
-ftb-zstyle -m single-group color || group_colors=("$default_color")
|
||||
fi
|
||||
|
||||
if (( $+builtins[fzf-tab-candidates-generate] )); then
|
||||
fzf-tab-candidates-generate
|
||||
else
|
||||
for k _v in "${(@ps:\2:)_ftb_compcap}"; do
|
||||
local -A v=("${(@0)_v}")
|
||||
[[ $v[word] == ${first_word:=$v[word]} ]] || same_word=0
|
||||
|
||||
# add character and color to describe the type of the files
|
||||
dsuf='' dpre=''
|
||||
if (( $+v[realdir] )); then
|
||||
filepath=$v[realdir]${(Q)v[word]}
|
||||
if [[ -d $filepath ]]; then
|
||||
dsuf=/
|
||||
fi
|
||||
# add color and resolve symlink if have list-colors
|
||||
# detail: http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcomplist-Module
|
||||
if (( $#list_colors )) && [[ -a $filepath || -L $filepath ]]; then
|
||||
-ftb-colorize $filepath
|
||||
colorful=1
|
||||
elif [[ -L $filepath ]]; then
|
||||
dsuf=@
|
||||
fi
|
||||
if [[ $options[list_types] == off ]]; then
|
||||
dsuf=''
|
||||
fi
|
||||
fi
|
||||
|
||||
# add color to description if they have group index
|
||||
if (( $+v[group] )); then
|
||||
local color=$group_colors[$v[group]]
|
||||
# add a hidden group index at start of string to keep group order when sorting
|
||||
# first group index is for builtin sort, sencond is for GNU sort
|
||||
tcandidates+=$v[group]$'\b'$color$prefix$dpre$'\0'$v[group]$'\b'$k$'\0'$dsuf
|
||||
else
|
||||
tcandidates+=$default_color$dpre$'\0'$k$'\0'$dsuf
|
||||
fi
|
||||
|
||||
# check group with duplicate member
|
||||
if [[ $show_group == brief ]]; then
|
||||
if (( $+word_map[$v[word]] && $+v[group] )); then
|
||||
duplicate_groups+=$v[group] # add this group
|
||||
duplicate_groups+=$word_map[$v[word]] # add previous group
|
||||
fi
|
||||
word_map[$v[word]]=$v[group]
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
(( same_word )) && tcandidates[2,-1]=()
|
||||
|
||||
# sort and remove sort group or other index
|
||||
zstyle -T ":completion:$_ftb_curcontext" sort
|
||||
if (( $? != 1 )); then
|
||||
if (( colorful )); then
|
||||
# if enable list_colors, we should skip the first field
|
||||
if [[ ${commands[sort]:A:t} != (|busybox*) ]]; then
|
||||
# this is faster but doesn't work if `find` is from busybox
|
||||
tcandidates=(${(f)"$(command sort -u -t '\0' -k 2 <<< ${(pj:\n:)tcandidates})"})
|
||||
else
|
||||
# slower but portable
|
||||
tcandidates=(${(@o)${(@)tcandidates:/(#b)([^$'\0']#)$'\0'(*)/$match[2]$'\0'$match[1]}})
|
||||
tcandidates=(${(@)tcandidates/(#b)(*)$'\0'([^$'\0']#)/$match[2]$'\0'$match[1]})
|
||||
fi
|
||||
else
|
||||
tcandidates=("${(@o)tcandidates}")
|
||||
fi
|
||||
fi
|
||||
typeset -gUa _ftb_complist=("${(@)tcandidates//[0-9]#$bs}")
|
||||
|
||||
# hide needless group
|
||||
if (( $#_ftb_groups )); then
|
||||
local i to_hide indexs=({1..$#_ftb_groups})
|
||||
case $show_group in
|
||||
brief) to_hide=(${indexs:|duplicate_groups}) ;;
|
||||
none) to_hide=($indexs) ;;
|
||||
esac
|
||||
for i in $to_hide; do
|
||||
# NOTE: _ftb_groups is unique array
|
||||
_ftb_groups[i]="__hide__$i"
|
||||
done
|
||||
fi
|
@ -0,0 +1,35 @@
|
||||
#!/hint/zsh
|
||||
|
||||
typeset -ga _ftb_headers=()
|
||||
local i tmp group_colors
|
||||
local -i mlen=0 len=0
|
||||
|
||||
if (( $#_ftb_groups == 1 )) && { ! -ftb-zstyle -m single-group "header" }; then
|
||||
return
|
||||
fi
|
||||
|
||||
# calculate the max column width
|
||||
for i in $_ftb_groups; do
|
||||
(( $#i > mlen )) && mlen=$#i
|
||||
done
|
||||
mlen+=1
|
||||
|
||||
-ftb-zstyle -a group-colors group_colors || group_colors=($_ftb_group_colors)
|
||||
|
||||
for (( i=1; i<=$#_ftb_groups; i++ )); do
|
||||
[[ $_ftb_groups[i] == "__hide__"* ]] && continue
|
||||
|
||||
if (( len + $#_ftb_groups[i] > COLUMNS - 5 )); then
|
||||
_ftb_headers+=$tmp
|
||||
tmp='' && len=0
|
||||
fi
|
||||
if (( len + mlen > COLUMNS - 5 )); then
|
||||
# the last column doesn't need padding
|
||||
_ftb_headers+=$tmp$group_colors[i]$_ftb_groups[i]$'\033[00m'
|
||||
tmp='' && len=0
|
||||
else
|
||||
tmp+=$group_colors[i]${(r:$mlen:)_ftb_groups[i]}$'\033[00m'
|
||||
len+=$mlen
|
||||
fi
|
||||
done
|
||||
(( $#tmp )) && _ftb_headers+=$tmp
|
@ -0,0 +1,40 @@
|
||||
#!/hint/zsh
|
||||
|
||||
if zmodload -s zsh/pcre; then
|
||||
setopt localoptions rematch_pcre
|
||||
fi
|
||||
|
||||
local key qtype tmp query_string
|
||||
typeset -g _ftb_query=
|
||||
-ftb-zstyle -a query-string query_string || query_string=(prefix input first)
|
||||
for qtype in $query_string; do
|
||||
if [[ $qtype == prefix ]]; then
|
||||
# find the longest common prefix among descriptions
|
||||
local -a keys=(${_ftb_compcap%$'\2'*})
|
||||
tmp=$keys[1]
|
||||
local MATCH match mbegin mend prefix=(${(s::)tmp})
|
||||
for key in ${keys:1}; do
|
||||
(( $#tmp )) || break
|
||||
[[ $key == $tmp* ]] && continue
|
||||
# interpose characters from the current common prefix and $key and see how
|
||||
# many pairs of equal characters we get at the start of the resulting string
|
||||
[[ ${(j::)${${(s::)key[1,$#tmp]}:^prefix}} =~ '^(((.)\3)*)' ]]
|
||||
# truncate common prefix and maintain loop invariant: ${(s::)tmp} == $prefix
|
||||
tmp[$#MATCH/2+1,-1]=""
|
||||
prefix[$#MATCH/2+1,-1]=()
|
||||
done
|
||||
elif [[ $qtype == input ]]; then
|
||||
local fv=${_ftb_compcap[1]#*$'\2'}
|
||||
local -A v=("${(@0)fv}")
|
||||
tmp=$v[PREFIX]
|
||||
if (( $RBUFFER[(i)$v[SUFFIX]] != 1 )); then
|
||||
tmp=${tmp/%$v[SUFFIX]}
|
||||
fi
|
||||
tmp=${${tmp#$v[hpre]}#$v[apre]}
|
||||
fi
|
||||
if (( $query_string[(I)longest] )); then
|
||||
(( $#tmp > $#_ftb_query )) && _ftb_query=$tmp
|
||||
elif [[ -n $tmp ]]; then
|
||||
_ftb_query=$tmp && break
|
||||
fi
|
||||
done
|
38
.config/zsh/config/omz/plugins/fzf-tab/lib/ftb-switch-group
Normal file
38
.config/zsh/config/omz/plugins/fzf-tab/lib/ftb-switch-group
Normal file
@ -0,0 +1,38 @@
|
||||
#!/hint/zsh
|
||||
emulate -L zsh -o extended_glob
|
||||
|
||||
zmodload zsh/mapfile
|
||||
|
||||
# receive arguments
|
||||
local pid=$1 header_lines=$2 tmp_dir=$3 offset=$@[-1]
|
||||
|
||||
# read completion list
|
||||
local -a list=(${(f)mapfile[$tmp_dir/completions.$pid]})
|
||||
|
||||
# get total group count
|
||||
if (( $#list > 10000 )); then
|
||||
local -Ua total=(${(f)"$(print -l ${list:$header_lines} | grep -a -oP '^\x1b\[[0-9;]*m')"})
|
||||
else
|
||||
local -Ua total=(${(M)${list:$header_lines}#$'\x1b['[0-9;]#*m})
|
||||
fi
|
||||
|
||||
# get current group index, start from 2
|
||||
local current=2
|
||||
if [[ -f $tmp_dir/current-group.$pid ]]; then
|
||||
current=$(( $(<$tmp_dir/current-group.$pid) + offset ))
|
||||
fi
|
||||
(( current > $#total )) && current=1
|
||||
(( current == 0 )) && current=$#total
|
||||
echo $current > $tmp_dir/current-group.$pid
|
||||
|
||||
# print headers
|
||||
if (( header_lines != 0 )); then
|
||||
print -l ${list[1,header_lines]/${total[current]}/$'\x1b[1m'}
|
||||
fi
|
||||
|
||||
# print current group
|
||||
if (( $#list > 10000 )); then
|
||||
print -l ${list:$header_lines} | grep -a -F "${total[current]}"
|
||||
else
|
||||
print -l ${(M)${list:$header_lines}:#${total[current]}*}
|
||||
fi
|
88
.config/zsh/config/omz/plugins/fzf-tab/lib/ftb-tmux-popup
Executable file
88
.config/zsh/config/omz/plugins/fzf-tab/lib/ftb-tmux-popup
Executable file
@ -0,0 +1,88 @@
|
||||
#!/hint/zsh
|
||||
# Show results with tmux popup
|
||||
# Example usage:
|
||||
# zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup
|
||||
# zstyle ':fzf-tab:*' popup-pad 0 0
|
||||
# It can also be used as a standalone tool, like:
|
||||
# ls | ftb-tmux-popup
|
||||
emulate -L zsh -o extended_glob
|
||||
|
||||
# import min
|
||||
autoload -Uz zmathfunc
|
||||
zmathfunc
|
||||
|
||||
: ${tmp_dir:=${TMPPREFIX:-/tmp/zsh}-fzf-tab-$USER}
|
||||
|
||||
# fallback to fzf if it is not running in tmux
|
||||
if (( ! $+TMUX_PANE )); then
|
||||
fzf $@
|
||||
return
|
||||
fi
|
||||
|
||||
local ret=0
|
||||
|
||||
local -a fzf_opts=($@)
|
||||
fzf_opts=(${${fzf_opts/--height*}/--layout*})
|
||||
|
||||
# get position of cursor and size of window
|
||||
local -a tmp=($(command tmux display-message -p "#{pane_top} #{cursor_y} #{pane_left} #{cursor_x} #{window_height} #{window_width} #{status} #{status-position}"))
|
||||
local cursor_y=$((tmp[1] + tmp[2])) cursor_x=$((tmp[3] + tmp[4])) window_height=$tmp[5] window_width=$tmp[6] window_top=0
|
||||
|
||||
if [[ $tmp[8] == 'top' ]]; then
|
||||
window_top=$tmp[7]
|
||||
cursor_y=$((cursor_y + window_top))
|
||||
fi
|
||||
|
||||
# if not called by fzf-tab
|
||||
if (( ! $+IN_FZF_TAB )); then
|
||||
[[ -d $tmp_dir ]] || mkdir -p $tmp_dir
|
||||
cat > $tmp_dir/completions.$$
|
||||
fi
|
||||
|
||||
local text REPLY comp_lines comp_length length popup_pad
|
||||
|
||||
zstyle -a ":fzf-tab:$_ftb_curcontext" popup-pad popup_pad || popup_pad=(0 0)
|
||||
|
||||
# get the size of content, note we should remove all ANSI color code
|
||||
comp_lines=$(( ${#${(f)mapfile[$tmp_dir/completions.$$]}} + $popup_pad[2] ))
|
||||
if (( comp_lines <= 500 )); then
|
||||
comp_length=0
|
||||
for line in ${(f)mapfile[$tmp_dir/completions.$$]}; do
|
||||
length=${(m)#${(S)line//$'\x1b['[0-9]#*m}}
|
||||
(( length >= comp_length )) && comp_length=$length
|
||||
done
|
||||
else
|
||||
# FIXME: can't get the correct width of CJK characters.
|
||||
comp_length=$( command perl -ne 's/\x1b\[[0-9;]*m//g;s/\x00//g; $m= length() if $m < length(); END { print $m }' < $tmp_dir/completions.$$ )
|
||||
fi
|
||||
comp_length=$(( comp_length + $popup_pad[1] ))
|
||||
|
||||
local popup_height popup_y popup_width popup_x
|
||||
|
||||
# calculate the popup height and y position
|
||||
if (( cursor_y * 2 > window_height )); then
|
||||
# show above the cursor
|
||||
popup_height=$(( min(comp_lines + 4, cursor_y - window_top) ))
|
||||
popup_y=$cursor_y
|
||||
else
|
||||
# show below the cursor
|
||||
popup_height=$(( min(comp_lines + 4, window_height - cursor_y + window_top - 1) ))
|
||||
popup_y=$(( cursor_y + popup_height + 1 ))
|
||||
fzf_opts+=(--layout=reverse)
|
||||
fi
|
||||
|
||||
# calculate the popup width and x position
|
||||
popup_width=$(( min(comp_length + 5, window_width) ))
|
||||
popup_x=$(( cursor_x + popup_width > window_width ? window_width - popup_width : cursor_x ))
|
||||
|
||||
echo -E "$commands[fzf] ${(qq)fzf_opts[@]} < $tmp_dir/completions.$$ > $tmp_dir/result-$$" > $tmp_dir/fzf-$$
|
||||
{
|
||||
tmux popup -x $popup_x -y $popup_y \
|
||||
-w $popup_width -h $popup_height \
|
||||
-d $PWD -E ". $tmp_dir/fzf-$$" || ret=$?
|
||||
echo -E "$(<$tmp_dir/result-$$)"
|
||||
} always {
|
||||
command rm $tmp_dir/*-$$
|
||||
(( $+IN_FZF_TAB )) || command rm $tmp_dir/completions.$$
|
||||
}
|
||||
return $ret
|
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Gamma
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,114 @@
|
||||
# zsh-ls-colors
|
||||
|
||||
![Demo screenshot](https://raw.githubusercontent.com/xPMo/zsh-ls-colors/image/demo.png)
|
||||
|
||||
A zsh library to use `LS_COLORS` in scripts or other plugins.
|
||||
|
||||
For a simple demo, see the `demo` script in this repo.
|
||||
|
||||
For more advanced usage,
|
||||
instructions are located at top of the source files for `from-mode` and `from-name`.
|
||||
If a use case isn't adequately covered,
|
||||
please open an issue!
|
||||
|
||||
## Using zsh-ls-colors in a plugin
|
||||
|
||||
You can use this as a submodule or a subtree.
|
||||
|
||||
### submodule:
|
||||
|
||||
```sh
|
||||
# Add (only once)
|
||||
git submodule add git://github.com/xPMo/zsh-ls-colors.git ls-colors
|
||||
git commit -m 'Add ls-colors as submodule'
|
||||
|
||||
# Update
|
||||
cd ls-colors
|
||||
git fetch
|
||||
git checkout origin/master
|
||||
cd ..
|
||||
git commit ls-colors -m 'Update ls-colors to latest'
|
||||
```
|
||||
|
||||
### Subtree:
|
||||
|
||||
```sh
|
||||
# Initial add
|
||||
git subtree add --prefix=ls-colors/ --squash -m 'Add ls-colors as a subtree' \
|
||||
git://github.com/xPMo/zsh-ls-colors.git master
|
||||
|
||||
# Update
|
||||
git subtree pull --prefix=ls-colors/ --squash -m 'Update ls-colors to latest' \
|
||||
git://github.com/xPMo/zsh-ls-colors.git master
|
||||
|
||||
|
||||
# Or, after adding a remote:
|
||||
git remote add ls-colors git://github.com/xPMo/zsh-ls-colors.git
|
||||
|
||||
# Initial add
|
||||
git subtree add --prefix=ls-colors/ --squash -m 'Add ls-colors as a subtree' ls-colors master
|
||||
|
||||
# Update
|
||||
git subtree pull --prefix=ls-colors/ --squash -m 'Update ls-colors to latest' ls-colors master
|
||||
```
|
||||
|
||||
### Function namespacing
|
||||
|
||||
Since functions are a public namespace,
|
||||
this plugin allows you to customize the preifix for your plugin:
|
||||
|
||||
```zsh
|
||||
# load functions as my-lscolors::{init,match-by,from-name,from-mode}
|
||||
source ${0:h}/ls-colors/ls-colors.zsh my-lscolors
|
||||
```
|
||||
|
||||
### Parameter namespacing
|
||||
|
||||
While indirect parameter expansion exists with `${(P)var}`,
|
||||
it doesn't play nicely with array parameters.
|
||||
|
||||
There are multiple strategies to prevent unnecessary re-parsing:
|
||||
|
||||
```zsh
|
||||
# Call once when loading.
|
||||
# Pollutes global namespace but prevents re-parsing
|
||||
ls-color::init
|
||||
```
|
||||
|
||||
```zsh
|
||||
# Don't call init at all and only use ::match-by.
|
||||
# Doesn't pollute global namespace but reparses LS_COLORS on every call
|
||||
ls-color::match-by $file lstat
|
||||
```
|
||||
|
||||
```zsh
|
||||
# Initialize within a scope with local parameters.
|
||||
# Best for not polluting global namespace when multiple filenames need to be parsed.
|
||||
(){
|
||||
local -A namecolors modecolors
|
||||
ls-color::init
|
||||
|
||||
for arg; do
|
||||
...
|
||||
done
|
||||
}
|
||||
```
|
||||
|
||||
```zsh
|
||||
# Serialize:
|
||||
typeset -g LS_COLORS_CACHE_FILE=$(mktemp)
|
||||
(){
|
||||
local -A namecolors modecolors
|
||||
ls-color::init
|
||||
typeset -p modecolors namecolors >| $LS_COLORS_CACHE_FILE
|
||||
zcompile $LS_COLORS_CACHE_FILE
|
||||
}
|
||||
|
||||
my-function(){
|
||||
local -A namecolors modecolors
|
||||
source $LS_COLORS_CACHE_FILE
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
65
.config/zsh/config/omz/plugins/fzf-tab/lib/zsh-ls-colors/demo
Executable file
65
.config/zsh/config/omz/plugins/fzf-tab/lib/zsh-ls-colors/demo
Executable file
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env zsh
|
||||
# set $0 (ref: zdharma.org/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html#zero-handling)
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
|
||||
# load library functions
|
||||
source ls-colors.zsh ''
|
||||
|
||||
# to name the functions with a different namespace
|
||||
# call source with a different argument
|
||||
#source my-plugin::ls
|
||||
|
||||
# init (sets modecolors and namecolors)
|
||||
# You have options. Either you can pollute global namespace:
|
||||
ls-color::init
|
||||
# Or you can have ::match-by re-parse colors on every call
|
||||
: # (do nothing)
|
||||
# Or if you have multiple calls, you can parse colors once for a scope:
|
||||
(){
|
||||
local -A modecolors namecolors
|
||||
ls-color::init
|
||||
|
||||
for arg; do
|
||||
ls-color::match-by $arg lstat
|
||||
: do something else
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# colors can also be added for other globs after init as well:
|
||||
namecolors[*.md]='01' # bold markdown files
|
||||
|
||||
# EXTENDED_GLOB is enabled when matching, so things like this are possible:
|
||||
namecolors[(#i)(*/|)license(|.*)]='04' # underline LICENSE, or license.txt, or similar
|
||||
|
||||
local file reply
|
||||
# color each file in the argument list
|
||||
for file; do
|
||||
ls-color::match-by $file all
|
||||
# point to symlink resolution if it exists
|
||||
print '\e['$reply[1]'m'$file'\e[0m'${reply[2]:+' → \e['$reply[3]'m'$reply[2]'\e[0m'}
|
||||
done
|
||||
|
||||
# =======================
|
||||
# Alternate manual method:
|
||||
for file; do
|
||||
ls-color::match-by $file lstat follow
|
||||
if [[ $reply[2] ]]; then
|
||||
# This is a symlink
|
||||
symlink_color=$reply[1]
|
||||
# If broken, use link color for destination
|
||||
resolved_color=$reply[1]
|
||||
resolved=$reply[2]
|
||||
if [[ -e $file ]]; then
|
||||
# Not broken, update destination color
|
||||
ls-color::match-by $file stat
|
||||
resolved_color=$reply[1]
|
||||
fi
|
||||
print '\e['$symlink_color'm'$file'\e[0m → \e['$resolved_color'm'$resolved'\e[0m'
|
||||
else
|
||||
# This is not a symlink
|
||||
print '\e['$reply[1]'m'$file'\e[0m'
|
||||
fi
|
||||
done
|
||||
|
@ -0,0 +1,186 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
# set the prefix for all functions
|
||||
local pfx=${1:-'ls-color'}
|
||||
|
||||
# {{{ From mode
|
||||
# Usage:
|
||||
# $1: filename
|
||||
# $2: The value of struct stat st_mode
|
||||
# If empty, modecolors lookup will be skipped
|
||||
# $3: (If symlink) The value of struct stat st_mode
|
||||
# for the target of $1's symlink. If unset,
|
||||
# interpret as a broken link.
|
||||
# Sets REPLY to the console code
|
||||
${pfx}::from-mode () {
|
||||
|
||||
emulate -L zsh
|
||||
setopt cbases octalzeroes extendedglob
|
||||
|
||||
[[ -z $2 ]] && return 1
|
||||
|
||||
local -i reg=0
|
||||
local -a codes
|
||||
|
||||
local -i st_mode=$(($2))
|
||||
# See man 7 inode for more info
|
||||
# file type
|
||||
case $(( st_mode & 0170000 )) in
|
||||
$(( 0140000 )) ) codes=( $modecolors[so] ) ;;
|
||||
$(( 0120000 )) ) # symlink, special handling
|
||||
if ! (($+3)); then
|
||||
REPLY=$modecolors[or]
|
||||
elif [[ $modecolors[ln] = target ]]; then
|
||||
"$0" "$1" "${@:3}"
|
||||
else
|
||||
REPLY=$modecolors[ln]
|
||||
fi
|
||||
return
|
||||
;;
|
||||
$(( 0100000 )) ) codes=( ); reg=1 ;; # regular file
|
||||
$(( 0060000 )) ) codes=( $modecolors[bd] ) ;;
|
||||
$(( 0040000 )) ) codes=( $modecolors[di] ) ;;
|
||||
$(( 0020000 )) ) codes=( $modecolors[cd] ) ;;
|
||||
$(( 0010000 )) ) codes=( $modecolors[pi] ) ;;
|
||||
esac
|
||||
|
||||
# setuid/setgid/sticky/other-writable
|
||||
(( st_mode & 04000 )) && codes+=( $modecolors[su] )
|
||||
(( st_mode & 02000 )) && codes+=( $modecolors[sg] )
|
||||
(( ! reg )) && case $(( st_mode & 01002 )) in
|
||||
# sticky
|
||||
$(( 01000 )) ) codes+=( $modecolors[st] ) ;;
|
||||
# other-writable
|
||||
$(( 00002 )) ) codes+=( $modecolors[ow] ) ;;
|
||||
# other-writable and sticky
|
||||
$(( 01002 )) ) codes+=( $modecolors[tw] ) ;;
|
||||
esac
|
||||
|
||||
# executable
|
||||
if (( ! $#codes )); then
|
||||
(( st_mode & 0111 )) && codes+=( $modecolors[ex] )
|
||||
fi
|
||||
|
||||
# return nonzero if no matching code
|
||||
[[ ${REPLY::=${(j:;:)codes}} ]]
|
||||
} # }}}
|
||||
# {{{ From name
|
||||
# Usage:
|
||||
# $1: filename
|
||||
#
|
||||
# Sets REPLY to the console code
|
||||
${pfx}::from-name () {
|
||||
|
||||
emulate -L zsh
|
||||
setopt extendedglob
|
||||
|
||||
# Return non-zero if no keys match
|
||||
[[ ${REPLY::=$namecolors[(k)$1]} ]]
|
||||
} # }}}
|
||||
# {{{ Init
|
||||
# WARNING: initializes namecolors and modecolors in global scope
|
||||
${pfx}::init () {
|
||||
emulate -L zsh
|
||||
|
||||
# Use $1 if provided, otherwise use LS_COLORS
|
||||
# Use LSCOLORS on BSD
|
||||
local LS_COLORS=${1:-${LS_COLORS:-$LSCOLORS}}
|
||||
|
||||
# read in LS_COLORS
|
||||
typeset -gA namecolors=(${(@s:=:)${(@s.:.)LS_COLORS}:#[[:alpha:]][[:alpha:]]=*})
|
||||
typeset -gA modecolors=(${(@Ms:=:)${(@s.:.)LS_COLORS}:#[[:alpha:]][[:alpha:]]=*})
|
||||
}
|
||||
# }}}
|
||||
# {{{ Match by
|
||||
# Usage:
|
||||
# $1: filename
|
||||
# Optional (must be $2): g[lobal]: Use existing stat | lstat in parent scope
|
||||
# ${@:2}: Append to reply:
|
||||
# - l[stat] : Look up using lstat (don't follow symlink), if empty match name
|
||||
# - s[tat] : Look up using stat (do follow symlink), if empty match name
|
||||
# - n[ame] : Only match name
|
||||
# - f[ollow]: Get resolution path of symlink
|
||||
# - L[stat] : Same as above but don't match name
|
||||
# - S[tat] : Same as above but don't match name
|
||||
# - a[ll] : If a broken symlink: lstat follow lstat
|
||||
# : If a symlink : lstat follow stat
|
||||
# : Otherwise : lstat
|
||||
# - A[ll] : If a broken symlink: Lstat follow Lstat
|
||||
# : If a symlink : Lstat follow Stat
|
||||
# : Otherwise : Lstat
|
||||
#
|
||||
# or returns non-zero
|
||||
${pfx}::match-by () {
|
||||
emulate -L zsh
|
||||
setopt extendedglob cbases octalzeroes
|
||||
|
||||
local arg REPLY name=$1 pfx=${0%::match-by}
|
||||
shift
|
||||
|
||||
# init in local scope if not using global params
|
||||
if ! [[ -v namecolors && -v modecolors ]]; then
|
||||
local -A namecolors modecolors
|
||||
${pfx}::init
|
||||
fi
|
||||
|
||||
if [[ ${1:l} = (g|global) ]]; then
|
||||
shift
|
||||
else
|
||||
local -a stat lstat
|
||||
declare -ga reply=()
|
||||
fi
|
||||
|
||||
zmodload -F zsh/stat b:zstat
|
||||
for arg; do
|
||||
case ${arg[1]:l} in
|
||||
n|name)
|
||||
${pfx}::from-name $name
|
||||
reply+=("$REPLY")
|
||||
;;
|
||||
l|lstat)
|
||||
(($#lstat)) || zstat -A lstat -L $name || return 1
|
||||
if ((lstat[3] & 0170000 )); then
|
||||
# follow symlink
|
||||
(($#stat)) || zstat -A stat $name 2>/dev/null
|
||||
fi
|
||||
${pfx}::from-mode "$name" "$lstat[3]" $stat[3]
|
||||
if [[ $REPLY || ${2[1]} = L ]]; then
|
||||
reply+=("$REPLY")
|
||||
else # fall back to name
|
||||
"$0" "$name" g n
|
||||
fi
|
||||
;;
|
||||
s|stat)
|
||||
(($#stat)) || zstat -A stat $name || return 1
|
||||
${pfx}::from-mode $name $stat[3]
|
||||
reply+=("$REPLY")
|
||||
if [[ $REPLY || ${arg[1]} = S ]]; then
|
||||
reply+=("$REPLY")
|
||||
else # fall back to name
|
||||
"$0" "$name" g n
|
||||
fi
|
||||
;;
|
||||
f|follow)
|
||||
(($#lstat)) || zstat -A lstat -L $name || return 1
|
||||
reply+=("$lstat[14]")
|
||||
;;
|
||||
a|all)
|
||||
# Match case
|
||||
"$0" "$name" g ${${${arg[1]%a}:+L}:-l}
|
||||
# won't append if empty
|
||||
reply+=($lstat[14])
|
||||
# $stat[14] will be empty if not a symlink
|
||||
if [[ $lstat[14] ]]; then
|
||||
if [[ -e $name ]]; then
|
||||
"$0" "$name" g ${${${arg[1]%a}:+S}:-s}
|
||||
else
|
||||
reply+=($reply[-2])
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*) return 2 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
# }}}
|
||||
# vim: set foldmethod=marker:
|
16
.config/zsh/config/omz/plugins/fzf-tab/modules/.cvsignore
vendored
Normal file
16
.config/zsh/config/omz/plugins/fzf-tab/modules/.cvsignore
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
Makefile
|
||||
META-FAQ
|
||||
config.cache
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.modules
|
||||
config.modules.sh
|
||||
config.status
|
||||
configure
|
||||
cscope.out
|
||||
stamp-h
|
||||
stamp-h.in
|
||||
autom4te.cache
|
||||
*.swp
|
||||
.git
|
4
.config/zsh/config/omz/plugins/fzf-tab/modules/.distfiles
vendored
Normal file
4
.config/zsh/config/omz/plugins/fzf-tab/modules/.distfiles
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
DISTFILES_SRC='
|
||||
META-FAQ
|
||||
configure config.h.in stamp-h.in
|
||||
'
|
15
.config/zsh/config/omz/plugins/fzf-tab/modules/.editorconfig
vendored
Normal file
15
.config/zsh/config/omz/plugins/fzf-tab/modules/.editorconfig
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Top-most editorconfig file
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
tab_width = 8
|
||||
indent_size = 2
|
||||
indent_style = tab
|
||||
|
||||
[ChangeLog]
|
||||
indent_size = 8
|
||||
|
||||
[*.[ch]]
|
||||
indent_size = 4
|
155
.config/zsh/config/omz/plugins/fzf-tab/modules/.gitignore
vendored
Normal file
155
.config/zsh/config/omz/plugins/fzf-tab/modules/.gitignore
vendored
Normal file
@ -0,0 +1,155 @@
|
||||
Makefile
|
||||
tags
|
||||
TAGS
|
||||
*.o
|
||||
*.o.c
|
||||
*.orig
|
||||
*.a
|
||||
*.so
|
||||
*.dll
|
||||
*~
|
||||
.*.sw?
|
||||
\#*
|
||||
|
||||
/META-FAQ
|
||||
/config.cache
|
||||
/config.h
|
||||
/config.log
|
||||
/config.modules
|
||||
/config.modules.sh
|
||||
/config.status
|
||||
/config.status.lineno
|
||||
/cscope.out
|
||||
/stamp-h
|
||||
/autom4te.cache
|
||||
|
||||
Config/defs.mk
|
||||
|
||||
CVS
|
||||
.#*
|
||||
|
||||
Doc/help
|
||||
Doc/help.txt
|
||||
Doc/help/[_a-zA-Z0-9]*
|
||||
|
||||
Doc/intro.pdf
|
||||
Doc/intro.ps
|
||||
Doc/intro.a4.pdf
|
||||
Doc/intro.a4.ps
|
||||
Doc/intro.us.pdf
|
||||
Doc/intro.us.ps
|
||||
Doc/version.yo
|
||||
Doc/texi2html.conf
|
||||
Doc/zsh*.1
|
||||
Doc/zsh.texi
|
||||
Doc/zsh.info*
|
||||
Doc/*.html
|
||||
Doc/zsh.aux
|
||||
Doc/zsh.toc
|
||||
Doc/zsh.cp
|
||||
Doc/zsh.cps
|
||||
Doc/zsh.fn
|
||||
Doc/zsh.fns
|
||||
Doc/zsh.ky
|
||||
Doc/zsh.kys
|
||||
Doc/zsh.pg
|
||||
Doc/zsh.pgs
|
||||
Doc/zsh.vr
|
||||
Doc/zsh.vrs
|
||||
Doc/zsh.log
|
||||
Doc/zsh.dvi
|
||||
Doc/zsh_a4.dvi
|
||||
Doc/zsh_us.dvi
|
||||
Doc/zsh.tp
|
||||
Doc/zsh.tps
|
||||
Doc/zsh.idx
|
||||
Doc/zsh_*.ps
|
||||
Doc/infodir
|
||||
Doc/zsh.pdf
|
||||
Doc/zsh_a4.pdf
|
||||
Doc/zsh_us.pdf
|
||||
|
||||
Doc/Zsh/modlist.yo
|
||||
Doc/Zsh/modmenu.yo
|
||||
Doc/Zsh/manmodmenu.yo
|
||||
|
||||
Etc/FAQ
|
||||
Etc/FAQ.html
|
||||
|
||||
Src/*.epro
|
||||
Src/*.export
|
||||
Src/*.mdh
|
||||
Src/*.mdh.tmp
|
||||
Src/*.mdhi
|
||||
Src/*.mdhs
|
||||
Src/*.syms
|
||||
Src/Makemod.in
|
||||
Src/Makemod
|
||||
Src/[_a-zA-Z0-9]*.pro
|
||||
Src/ansi2knr
|
||||
Src/bltinmods.list
|
||||
Src/cscope.out
|
||||
Src/libzsh.so*
|
||||
Src/modules-bltin
|
||||
Src/modules.index
|
||||
Src/modules.index.tmp
|
||||
Src/modules.stamp
|
||||
Src/patchlevel.h
|
||||
Src/sigcount.h
|
||||
Src/signames.c
|
||||
Src/signames2.c
|
||||
Src/stamp-modobjs
|
||||
Src/stamp-modobjs.tmp
|
||||
Src/tags
|
||||
Src/TAGS
|
||||
Src/version.h
|
||||
Src/zsh
|
||||
Src/zsh.exe
|
||||
Src/zshcurses.h
|
||||
Src/zshpaths.h
|
||||
Src/zshterm.h
|
||||
Src/zshxmods.h
|
||||
|
||||
Src/Builtins/Makefile.in
|
||||
Src/Builtins/*.export
|
||||
Src/Builtins/so_locations
|
||||
Src/Builtins/*.pro
|
||||
Src/Builtins/*.epro
|
||||
Src/Builtins/*.syms
|
||||
Src/Builtins/*.mdh
|
||||
Src/Builtins/*.mdhi
|
||||
Src/Builtins/*.mdhs
|
||||
Src/Builtins/*.mdh.tmp
|
||||
Src/Builtins/rlimits.h
|
||||
|
||||
Src/Modules/Makefile.in
|
||||
Src/Modules/*.export
|
||||
Src/Modules/so_locations
|
||||
Src/Modules/*.pro
|
||||
Src/Modules/*.epro
|
||||
Src/Modules/*.syms
|
||||
Src/Modules/*.mdh
|
||||
Src/Modules/*.mdhi
|
||||
Src/Modules/*.mdhs
|
||||
Src/Modules/*.mdh.tmp
|
||||
Src/Modules/errnames.c
|
||||
Src/Modules/errcount.h
|
||||
Src/Modules/curses_keys.h
|
||||
|
||||
Src/Zle/Makefile.in
|
||||
Src/Zle/*.export
|
||||
Src/Zle/so_locations
|
||||
Src/Zle/*.pro
|
||||
Src/Zle/*.epro
|
||||
Src/Zle/*.syms
|
||||
Src/Zle/*.mdh
|
||||
Src/Zle/*.mdhi
|
||||
Src/Zle/*.mdhs
|
||||
Src/Zle/*.mdh.tmp
|
||||
Src/Zle/thingies.list
|
||||
Src/Zle/widgets.list
|
||||
Src/Zle/zle_things.h
|
||||
Src/Zle/zle_widget.h
|
||||
|
||||
Test/*.tmp
|
||||
/.project
|
7
.config/zsh/config/omz/plugins/fzf-tab/modules/.preconfig
vendored
Executable file
7
.config/zsh/config/omz/plugins/fzf-tab/modules/.preconfig
vendored
Executable file
@ -0,0 +1,7 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
autoconf
|
||||
autoheader
|
||||
echo > stamp-h.in
|
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/.cvsignore
vendored
Normal file
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/.cvsignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
defs.mk
|
||||
*.swp
|
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/.distfiles
vendored
Normal file
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/.distfiles
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
DISTFILES_SRC='
|
||||
'
|
8
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/aczshoot.m4
vendored
Normal file
8
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/aczshoot.m4
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
AC_DEFUN([zsh_OOT],
|
||||
[
|
||||
AC_CHECK_HEADERS(stdarg.h varargs.h termios.h termio.h)
|
||||
|
||||
AC_TYPE_SIGNAL
|
||||
|
||||
AC_DEFINE([ZSH_OOT_MODULE], [], [Out-of-tree module])
|
||||
])
|
43
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/clean.mk
vendored
Normal file
43
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/clean.mk
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
#
|
||||
# Makefile fragment for cleanup
|
||||
#
|
||||
# Copyright (c) 1995-1997 Richard Coleman
|
||||
# All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, without written agreement and without
|
||||
# license or royalty fees, to use, copy, modify, and distribute this
|
||||
# software and to distribute modified versions of this software for any
|
||||
# purpose, provided that the above copyright notice and the following
|
||||
# two paragraphs appear in all copies of this software.
|
||||
#
|
||||
# In no event shall Richard Coleman or the Zsh Development Group be liable
|
||||
# to any party for direct, indirect, special, incidental, or consequential
|
||||
# damages arising out of the use of this software and its documentation,
|
||||
# even if Richard Coleman and the Zsh Development Group have been advised of
|
||||
# the possibility of such damage.
|
||||
#
|
||||
# Richard Coleman and the Zsh Development Group specifically disclaim any
|
||||
# warranties, including, but not limited to, the implied warranties of
|
||||
# merchantability and fitness for a particular purpose. The software
|
||||
# provided hereunder is on an "as is" basis, and Richard Coleman and the
|
||||
# Zsh Development Group have no obligation to provide maintenance,
|
||||
# support, updates, enhancements, or modifications.
|
||||
#
|
||||
|
||||
mostlyclean: mostlyclean-recursive mostlyclean-here
|
||||
clean: clean-recursive clean-here
|
||||
distclean: distclean-recursive distclean-here
|
||||
realclean: realclean-recursive realclean-here
|
||||
|
||||
mostlyclean-here:
|
||||
clean-here: mostlyclean-here
|
||||
distclean-here: clean-here
|
||||
realclean-here: distclean-here
|
||||
|
||||
mostlyclean-recursive clean-recursive distclean-recursive realclean-recursive:
|
||||
@subdirs='$(SUBDIRS)'; if test -n "$$subdirs"; then \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$subdirs; do \
|
||||
(cd $$subdir && $(MAKE) $(MAKEDEFS) $$target) || exit 1; \
|
||||
done; \
|
||||
fi
|
42
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/config.mk
vendored
Normal file
42
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/config.mk
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
#
|
||||
# Makefile fragment for building Makefiles
|
||||
#
|
||||
# Copyright (c) 1995-1997 Richard Coleman
|
||||
# All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, without written agreement and without
|
||||
# license or royalty fees, to use, copy, modify, and distribute this
|
||||
# software and to distribute modified versions of this software for any
|
||||
# purpose, provided that the above copyright notice and the following
|
||||
# two paragraphs appear in all copies of this software.
|
||||
#
|
||||
# In no event shall Richard Coleman or the Zsh Development Group be liable
|
||||
# to any party for direct, indirect, special, incidental, or consequential
|
||||
# damages arising out of the use of this software and its documentation,
|
||||
# even if Richard Coleman and the Zsh Development Group have been advised of
|
||||
# the possibility of such damage.
|
||||
#
|
||||
# Richard Coleman and the Zsh Development Group specifically disclaim any
|
||||
# warranties, including, but not limited to, the implied warranties of
|
||||
# merchantability and fitness for a particular purpose. The software
|
||||
# provided hereunder is on an "as is" basis, and Richard Coleman and the
|
||||
# Zsh Development Group have no obligation to provide maintenance,
|
||||
# support, updates, enhancements, or modifications.
|
||||
#
|
||||
|
||||
config: Makefile
|
||||
@subdirs='$(SUBDIRS)'; for subdir in $$subdirs; do \
|
||||
(cd $$subdir && $(MAKE) $(MAKEDEFS) $@) || exit 1; \
|
||||
done
|
||||
|
||||
CONFIG_INCS = \
|
||||
$(dir_top)/Config/clean.mk $(dir_top)/Config/config.mk \
|
||||
$(dir_top)/Config/defs.mk $(dir_top)/Config/version.mk
|
||||
|
||||
Makefile: Makefile.in $(dir_top)/config.status $(CONFIG_INCS)
|
||||
cd $(dir_top) && \
|
||||
$(SHELL) ./config.status `echo $(subdir)/$@ | sed 's%^./%%'`
|
||||
|
||||
$(dir_top)/Config/defs.mk: $(sdir_top)/Config/defs.mk.in $(dir_top)/config.status
|
||||
cd $(dir_top) && \
|
||||
$(SHELL) ./config.status Config/defs.mk
|
114
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/defs.mk.in
vendored
Normal file
114
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/defs.mk.in
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
#
|
||||
# Basic Makefile definitions
|
||||
#
|
||||
# Copyright (c) 1995-1997 Richard Coleman
|
||||
# All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, without written agreement and without
|
||||
# license or royalty fees, to use, copy, modify, and distribute this
|
||||
# software and to distribute modified versions of this software for any
|
||||
# purpose, provided that the above copyright notice and the following
|
||||
# two paragraphs appear in all copies of this software.
|
||||
#
|
||||
# In no event shall Richard Coleman or the Zsh Development Group be liable
|
||||
# to any party for direct, indirect, special, incidental, or consequential
|
||||
# damages arising out of the use of this software and its documentation,
|
||||
# even if Richard Coleman and the Zsh Development Group have been advised of
|
||||
# the possibility of such damage.
|
||||
#
|
||||
# Richard Coleman and the Zsh Development Group specifically disclaim any
|
||||
# warranties, including, but not limited to, the implied warranties of
|
||||
# merchantability and fitness for a particular purpose. The software
|
||||
# provided hereunder is on an "as is" basis, and Richard Coleman and the
|
||||
# Zsh Development Group have no obligation to provide maintenance,
|
||||
# support, updates, enhancements, or modifications.
|
||||
#
|
||||
|
||||
# fundamentals
|
||||
SHELL = /bin/sh
|
||||
@SET_MAKE@
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# headers
|
||||
ZSH_CURSES_H = @ZSH_CURSES_H@
|
||||
ZSH_TERM_H = @ZSH_TERM_H@
|
||||
|
||||
# install basename
|
||||
tzsh = @tzsh@
|
||||
|
||||
# installation directories
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
MODDIR = $(libdir)/$(tzsh)/$(VERSION)
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
datarootdir = @datarootdir@
|
||||
datadir = @datadir@
|
||||
fndir = @fndir@
|
||||
fixed_sitefndir = @fixed_sitefndir@
|
||||
sitefndir = @sitefndir@
|
||||
scriptdir = @scriptdir@
|
||||
sitescriptdir = @sitescriptdir@
|
||||
htmldir = @htmldir@
|
||||
runhelpdir = @runhelpdir@
|
||||
runhelp = @runhelp@
|
||||
|
||||
# compilation
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
DEFS = @DEFS@
|
||||
CFLAGS = @CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
|
||||
DLCFLAGS = @DLCFLAGS@
|
||||
DLLDFLAGS = @DLLDFLAGS@
|
||||
LIBLDFLAGS = @LIBLDFLAGS@
|
||||
EXELDFLAGS = @EXELDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
DL_EXT = @DL_EXT@
|
||||
DLLD = @DLLD@
|
||||
EXPOPT = @EXPOPT@
|
||||
IMPOPT = @IMPOPT@
|
||||
|
||||
# utilities
|
||||
AWK = @AWK@
|
||||
ANSI2KNR = @ANSI2KNR@
|
||||
YODL = @YODL@ @YODL_OPTIONS@
|
||||
YODL2TXT = @YODL@2txt
|
||||
YODL2HTML = @YODL@2html
|
||||
|
||||
# install utility
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
# variables used in determining what to install
|
||||
FUNCTIONS_SUBDIRS = @FUNCTIONS_SUBDIRS@
|
||||
|
||||
# Additional fpath entries (eg. for vendor specific directories).
|
||||
additionalfpath = @additionalfpath@
|
||||
|
||||
# flags passed to recursive makes in subdirectories
|
||||
MAKEDEFS = \
|
||||
prefix='$(prefix)' exec_prefix='$(exec_prefix)' bindir='$(bindir)' \
|
||||
libdir='$(libdir)' MODDIR='$(MODDIR)' infodir='$(infodir)' mandir='$(mandir)' \
|
||||
datadir='$(datadir)' fndir='$(fndir)' htmldir='$(htmldir)' runhelpdir='$(runhelpdir)' \
|
||||
CC='$(CC)' CPPFLAGS='$(CPPFLAGS)' DEFS='$(DEFS)' CFLAGS='$(CFLAGS)' \
|
||||
LDFLAGS='$(LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \
|
||||
DLCFLAGS='$(DLCFLAGS)' DLLDFLAGS='$(DLLDFLAGS)' \
|
||||
LIBLDFLAGS='$(LIBLDFLAGS)' EXELDFLAGS='$(EXELDFLAGS)' \
|
||||
LIBS='$(LIBS)' DL_EXT='$(DL_EXT)' DLLD='$(DLLD)' \
|
||||
AWK='$(AWK)' ANSI2KNR='$(ANSI2KNR)' \
|
||||
YODL='$(YODL)' YODL2TXT='$(YODL2TXT)' YODL2HTML='$(YODL2HTML)' \
|
||||
FUNCTIONS_INSTALL='$(FUNCTIONS_INSTALL)' tzsh='$(tzsh)'
|
||||
|
||||
# override built-in suffix list
|
||||
.SUFFIXES:
|
||||
|
||||
# parallel build is not supported (pmake, gmake)
|
||||
.NOTPARALLEL:
|
||||
|
||||
# parallel build is not supported (dmake)
|
||||
.NO_PARALLEL:
|
74
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/installfns.sh
vendored
Executable file
74
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/installfns.sh
vendored
Executable file
@ -0,0 +1,74 @@
|
||||
#!/bin/sh
|
||||
|
||||
fndir=$DESTDIR$fndir
|
||||
scriptdir=$DESTDIR$scriptdir
|
||||
|
||||
/bin/sh $sdir_top/mkinstalldirs $fndir || exit 1;
|
||||
|
||||
allfuncs="`grep ' functions=.' ${dir_top}/config.modules |
|
||||
sed -e '/^#/d' -e '/ link=no/d' -e 's/^.* functions=//'`"
|
||||
|
||||
allfuncs="`cd $sdir_top; echo ${allfuncs}`"
|
||||
|
||||
test -d installfnsdir || mkdir installfnsdir
|
||||
|
||||
# We now have a list of files, but we need to use `test -f' to check
|
||||
# (1) the glob got expanded (2) we are not looking at directories.
|
||||
for file in $allfuncs; do
|
||||
if test -f $sdir_top/$file; then
|
||||
case "$file" in
|
||||
*/CVS/*) continue;;
|
||||
esac
|
||||
if test x$FUNCTIONS_SUBDIRS != x && test x$FUNCTIONS_SUBDIRS != xno; then
|
||||
case "$file" in
|
||||
Completion/*/*)
|
||||
subdir="`echo $file | sed -e 's%/[^/]*/[^/]*$%%'`"
|
||||
instdir="$fndir/$subdir"
|
||||
;;
|
||||
Completion/*)
|
||||
instdir="$fndir/Completion"
|
||||
;;
|
||||
Scripts/*)
|
||||
instdir="$scriptdir"
|
||||
;;
|
||||
*)
|
||||
subdir="`echo $file | sed -e 's%/[^/]*$%%' -e 's%^Functions/%%'`"
|
||||
instdir="$fndir/$subdir"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
case "$file" in
|
||||
Scripts/*)
|
||||
instdir="$scriptdir"
|
||||
;;
|
||||
*)
|
||||
instdir="$fndir"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
basename=`basename $file`
|
||||
ok=0
|
||||
if test -d $instdir || /bin/sh $sdir_top/mkinstalldirs $instdir; then
|
||||
if sed "s|@runhelpdir@|$runhelpdir|" <$sdir_top/$file \
|
||||
>installfnsdir/$basename; then
|
||||
if $INSTALL_DATA installfnsdir/$basename $instdir; then
|
||||
ok=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
case $ok in
|
||||
0)
|
||||
rm -rf installfnsdir
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
read line < $sdir_top/$file
|
||||
case "$line" in
|
||||
'#!'*)
|
||||
chmod +x $instdir/`echo $file | sed -e 's%^.*/%%'`
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
rm -rf installfnsdir
|
59
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/uninstallfns.sh
vendored
Executable file
59
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/uninstallfns.sh
vendored
Executable file
@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
|
||||
fndir=$DESTDIR$fndir
|
||||
scriptdir=$DESTDIR$scriptdir
|
||||
|
||||
allfuncs="`grep ' functions=' ${dir_top}/config.modules |
|
||||
sed -e '/^#/d' -e '/ link=no/d' -e 's/^.* functions=//'`"
|
||||
|
||||
allfuncs="`cd ${sdir_top}; echo ${allfuncs}`"
|
||||
|
||||
case $fndir in
|
||||
*$VERSION*)
|
||||
# Version specific function directory, safe to remove completely.
|
||||
rm -rf $fndir
|
||||
;;
|
||||
*) # The following will only apply with a custom install directory
|
||||
# with no version information. This is rather undesirable.
|
||||
# But let's try and do the best we can.
|
||||
# We now have a list of files, but we need to use `test -f' to check
|
||||
# (1) the glob got expanded (2) we are not looking at directories.
|
||||
for file in $allfuncs; do
|
||||
case $file in
|
||||
Scripts/*)
|
||||
;;
|
||||
*)
|
||||
if test -f $sdir_top/$file; then
|
||||
if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
|
||||
file=`echo $file | sed -e 's%%^(Functions|Completion)/%'`
|
||||
rm -f $fndir/$file
|
||||
else
|
||||
bfile="`echo $file | sed -e 's%^.*/%%'`"
|
||||
rm -f "$fndir/$bfile"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
case $scriptdir in
|
||||
*$VERSION*)
|
||||
# $scriptdir might be the parent of fndir.
|
||||
rm -rf $scriptdir
|
||||
;;
|
||||
*) for file in $allfuncs; do
|
||||
case $file in
|
||||
Scripts/*)
|
||||
if test -f $sdir_top/$file; then
|
||||
bfile="`echo $file | sed -e 's%^.*/%%'`"
|
||||
rm -f "$scriptdir/$bfile"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
31
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/version.mk
vendored
Normal file
31
.config/zsh/config/omz/plugins/fzf-tab/modules/Config/version.mk
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Makefile fragment for version numbers
|
||||
#
|
||||
# Copyright (c) 1995-1997 Richard Coleman
|
||||
# All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, without written agreement and without
|
||||
# license or royalty fees, to use, copy, modify, and distribute this
|
||||
# software and to distribute modified versions of this software for any
|
||||
# purpose, provided that the above copyright notice and the following
|
||||
# two paragraphs appear in all copies of this software.
|
||||
#
|
||||
# In no event shall Richard Coleman or the Zsh Development Group be liable
|
||||
# to any party for direct, indirect, special, incidental, or consequential
|
||||
# damages arising out of the use of this software and its documentation,
|
||||
# even if Richard Coleman and the Zsh Development Group have been advised of
|
||||
# the possibility of such damage.
|
||||
#
|
||||
# Richard Coleman and the Zsh Development Group specifically disclaim any
|
||||
# warranties, including, but not limited to, the implied warranties of
|
||||
# merchantability and fitness for a particular purpose. The software
|
||||
# provided hereunder is on an "as is" basis, and Richard Coleman and the
|
||||
# Zsh Development Group have no obligation to provide maintenance,
|
||||
# support, updates, enhancements, or modifications.
|
||||
#
|
||||
|
||||
# This must also serve as a shell script, so do not add spaces around the
|
||||
# `=' signs.
|
||||
|
||||
VERSION=5.3.1-dev-0
|
||||
VERSION_DATE='December 22, 2016'
|
37
.config/zsh/config/omz/plugins/fzf-tab/modules/LICENCE
vendored
Normal file
37
.config/zsh/config/omz/plugins/fzf-tab/modules/LICENCE
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
Unless otherwise noted in the header of specific files, files in this
|
||||
distribution have the licence shown below.
|
||||
|
||||
However, note that certain shell functions are licensed under versions
|
||||
of the GNU General Public Licence. Anyone distributing the shell as a
|
||||
binary including those files needs to take account of this. Search
|
||||
shell functions for "Copyright" for specific copyright information.
|
||||
None of the core functions are affected by this, so those files may
|
||||
simply be omitted.
|
||||
|
||||
--
|
||||
|
||||
The Z Shell is copyright (c) 1992-2017 Paul Falstad, Richard Coleman,
|
||||
Zoltán Hidvégi, Andrew Main, Peter Stephenson, Sven Wischnowsky, and
|
||||
others. All rights reserved. Individual authors, whether or not
|
||||
specifically named, retain copyright in all changes; in what follows, they
|
||||
are referred to as `the Zsh Development Group'. This is for convenience
|
||||
only and this body has no legal status. The Z shell is distributed under
|
||||
the following licence; any provisions made in individual files take
|
||||
precedence.
|
||||
|
||||
Permission is hereby granted, without written agreement and without
|
||||
licence or royalty fees, to use, copy, modify, and distribute this
|
||||
software and to distribute modified versions of this software for any
|
||||
purpose, provided that the above copyright notice and the following
|
||||
two paragraphs appear in all copies of this software.
|
||||
|
||||
In no event shall the Zsh Development Group be liable to any party for
|
||||
direct, indirect, special, incidental, or consequential damages arising out
|
||||
of the use of this software and its documentation, even if the Zsh
|
||||
Development Group have been advised of the possibility of such damage.
|
||||
|
||||
The Zsh Development Group specifically disclaim any warranties, including,
|
||||
but not limited to, the implied warranties of merchantability and fitness
|
||||
for a particular purpose. The software provided hereunder is on an "as is"
|
||||
basis, and the Zsh Development Group have no obligation to provide
|
||||
maintenance, support, updates, enhancements, or modifications.
|
87
.config/zsh/config/omz/plugins/fzf-tab/modules/Makefile.in
vendored
Normal file
87
.config/zsh/config/omz/plugins/fzf-tab/modules/Makefile.in
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
#
|
||||
# Makefile for top level of zsh distribution
|
||||
#
|
||||
# Copyright (c) 1995-1997 Richard Coleman
|
||||
# All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, without written agreement and without
|
||||
# license or royalty fees, to use, copy, modify, and distribute this
|
||||
# software and to distribute modified versions of this software for any
|
||||
# purpose, provided that the above copyright notice and the following
|
||||
# two paragraphs appear in all copies of this software.
|
||||
#
|
||||
# In no event shall Richard Coleman or the Zsh Development Group be liable
|
||||
# to any party for direct, indirect, special, incidental, or consequential
|
||||
# damages arising out of the use of this software and its documentation,
|
||||
# even if Richard Coleman and the Zsh Development Group have been advised of
|
||||
# the possibility of such damage.
|
||||
#
|
||||
# Richard Coleman and the Zsh Development Group specifically disclaim any
|
||||
# warranties, including, but not limited to, the implied warranties of
|
||||
# merchantability and fitness for a particular purpose. The software
|
||||
# provided hereunder is on an "as is" basis, and Richard Coleman and the
|
||||
# Zsh Development Group have no obligation to provide maintenance,
|
||||
# support, updates, enhancements, or modifications.
|
||||
#
|
||||
|
||||
subdir = .
|
||||
dir_top = .
|
||||
SUBDIRS = Src
|
||||
|
||||
@VERSION_MK@
|
||||
|
||||
# source/build directories
|
||||
VPATH = @srcdir@
|
||||
sdir = @srcdir@
|
||||
sdir_top = @top_srcdir@
|
||||
INSTALL = @INSTALL@
|
||||
|
||||
@DEFS_MK@
|
||||
|
||||
# ========== DEPENDENCIES FOR BUILDING ==========
|
||||
|
||||
# default target
|
||||
all: config.h config.modules
|
||||
cd Src && $(MAKE) $(MAKEDEFS) $@
|
||||
|
||||
# prepare module configuration
|
||||
prep:
|
||||
@cd Src && $(MAKE) $(MAKEDEFS) $@
|
||||
|
||||
# ========== DEPENDENCIES FOR CLEANUP ==========
|
||||
|
||||
@CLEAN_MK@
|
||||
|
||||
distclean-here:
|
||||
rm -f Makefile config.h config.status config.log config.cache config.modules config.modules.sh stamp-h Config/defs.mk
|
||||
rm -rf autom4te.cache
|
||||
|
||||
realclean-here:
|
||||
cd $(sdir) && rm -f config.h.in stamp-h.in configure
|
||||
|
||||
# ========== DEPENDENCIES FOR MAINTENANCE ==========
|
||||
|
||||
@CONFIG_MK@
|
||||
|
||||
config: config.h
|
||||
|
||||
config.status: $(sdir)/configure
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
$(sdir)/configure: $(sdir)/aclocal.m4 $(sdir)/aczsh.m4 $(sdir)/configure.ac
|
||||
cd $(sdir) && autoconf
|
||||
|
||||
config.h: stamp-h
|
||||
stamp-h: $(sdir)/config.h.in config.status
|
||||
cd $(dir_top) && $(SHELL) ./config.status config.h $@
|
||||
|
||||
config.modules: $(sdir)/config.h.in config.status config.modules.sh
|
||||
cd $(dir_top) && $(SHELL) ./config.status $@ && \
|
||||
$(SHELL) ./config.modules.sh
|
||||
|
||||
$(sdir)/config.h.in: $(sdir)/stamp-h.in
|
||||
$(sdir)/stamp-h.in: $(sdir)/configure
|
||||
cd $(sdir) && autoheader
|
||||
echo > $(sdir)/stamp-h.in
|
||||
|
||||
FORCE:
|
1
.config/zsh/config/omz/plugins/fzf-tab/modules/RECOMPILE_REQUEST
vendored
Normal file
1
.config/zsh/config/omz/plugins/fzf-tab/modules/RECOMPILE_REQUEST
vendored
Normal file
@ -0,0 +1 @@
|
||||
1580588806
|
35
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/.cvsignore
vendored
Normal file
35
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/.cvsignore
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
*.dll
|
||||
*.epro
|
||||
*.export
|
||||
*.mdh
|
||||
*.mdh.tmp
|
||||
*.mdhi
|
||||
*.mdhs
|
||||
*.o
|
||||
*.o.c
|
||||
*.so
|
||||
*.swp
|
||||
*.syms
|
||||
Makefile
|
||||
Makemod.in Makemod
|
||||
[_a-zA-Z0-9]*.pro
|
||||
ansi2knr
|
||||
bltinmods.list
|
||||
cscope.out
|
||||
libzsh.so*
|
||||
modules-bltin
|
||||
modules.index
|
||||
modules.index.tmp
|
||||
modules.stamp
|
||||
patchlevel.h
|
||||
sigcount.h
|
||||
signames.c signames2.c
|
||||
stamp-modobjs
|
||||
stamp-modobjs.tmp
|
||||
tags TAGS
|
||||
version.h
|
||||
zsh
|
||||
zshcurses.h
|
||||
zshpaths.h
|
||||
zshterm.h
|
||||
zshxmods.h
|
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/.distfiles
vendored
Normal file
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/.distfiles
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
DISTFILES_SRC='
|
||||
'
|
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/.exrc
vendored
Normal file
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/.exrc
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
set ai
|
||||
set sw=4
|
27
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/.indent.pro
vendored
Normal file
27
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/.indent.pro
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
--dont-format-comments
|
||||
--procnames-start-lines
|
||||
--no-parameter-indentation
|
||||
--indent-level4
|
||||
--line-comments-indentation4
|
||||
--cuddle-else
|
||||
--brace-indent0
|
||||
--dont-star-comments
|
||||
--blank-lines-after-declarations
|
||||
--blank-lines-after-procedures
|
||||
--no-blank-lines-after-commas
|
||||
--comment-indentation33
|
||||
--declaration-comment-column33
|
||||
--no-comment-delimiters-on-blank-lines
|
||||
--continuation-indentation4
|
||||
--case-indentation0
|
||||
--else-endif-column33
|
||||
--no-space-after-casts
|
||||
--no-blank-before-sizeof
|
||||
--declaration-indentation0
|
||||
--continue-at-parentheses
|
||||
--no-space-after-function-call-names
|
||||
--swallow-optional-blank-lines
|
||||
--dont-space-special-semicolon
|
||||
--tab-size8
|
||||
--line-length132
|
||||
--braces-on-if-line
|
164
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/Makefile.in
vendored
Normal file
164
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/Makefile.in
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
#
|
||||
# Makefile for Src subdirectory
|
||||
#
|
||||
# Copyright (c) 1995-1997 Richard Coleman
|
||||
# All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, without written agreement and without
|
||||
# license or royalty fees, to use, copy, modify, and distribute this
|
||||
# software and to distribute modified versions of this software for any
|
||||
# purpose, provided that the above copyright notice and the following
|
||||
# two paragraphs appear in all copies of this software.
|
||||
#
|
||||
# In no event shall Richard Coleman or the Zsh Development Group be liable
|
||||
# to any party for direct, indirect, special, incidental, or consequential
|
||||
# damages arising out of the use of this software and its documentation,
|
||||
# even if Richard Coleman and the Zsh Development Group have been advised of
|
||||
# the possibility of such damage.
|
||||
#
|
||||
# Richard Coleman and the Zsh Development Group specifically disclaim any
|
||||
# warranties, including, but not limited to, the implied warranties of
|
||||
# merchantability and fitness for a particular purpose. The software
|
||||
# provided hereunder is on an "as is" basis, and Richard Coleman and the
|
||||
# Zsh Development Group have no obligation to provide maintenance,
|
||||
# support, updates, enhancements, or modifications.
|
||||
#
|
||||
|
||||
subdir = Src
|
||||
dir_top = ..
|
||||
SUBDIRS =
|
||||
|
||||
@VERSION_MK@
|
||||
|
||||
# source/build directories
|
||||
VPATH = @srcdir@
|
||||
sdir = @srcdir@
|
||||
sdir_top = @top_srcdir@
|
||||
INSTALL = @INSTALL@
|
||||
LN = @LN@
|
||||
|
||||
@DEFS_MK@
|
||||
|
||||
sdir_src = $(sdir)
|
||||
dir_src = .
|
||||
|
||||
# ========= DEPENDENCIES FOR BUILDING ==========
|
||||
|
||||
LINK = $(CC) $(LDFLAGS) $(EXELDFLAGS) $(EXTRA_LDFLAGS) -o $@
|
||||
DLLINK = $(DLLD) $(LDFLAGS) $(LIBLDFLAGS) $(DLLDFLAGS) -o $@
|
||||
|
||||
all: zsh.export modules
|
||||
.PHONY: all
|
||||
|
||||
modules: headers
|
||||
.PHONY: modules
|
||||
|
||||
L = @L@
|
||||
|
||||
LSTMP =
|
||||
LLIST =
|
||||
NSTMP = stamp-modobjs
|
||||
NLIST = `cat stamp-modobjs`
|
||||
|
||||
LIBZSH = libzsh-$(VERSION).$(DL_EXT)
|
||||
NIBZSH =
|
||||
INSTLIB = @INSTLIB@
|
||||
UNINSTLIB = @UNINSTLIB@
|
||||
|
||||
ZSH_EXPORT = $(EXPOPT)zsh.export
|
||||
ZSH_NXPORT =
|
||||
ENTRYOBJ = modentry..o
|
||||
NNTRYOBJ =
|
||||
|
||||
LDRUNPATH = LD_RUN_PATH=$(libdir)/$(tzsh)
|
||||
NDRUNPATH =
|
||||
|
||||
EXTRAZSHOBJS = @EXTRAZSHOBJS@
|
||||
|
||||
stamp-modobjs: modobjs
|
||||
@if cmp -s stamp-modobjs.tmp stamp-modobjs; then \
|
||||
rm -f stamp-modobjs.tmp; \
|
||||
echo "\`stamp-modobjs' is up to date."; \
|
||||
else \
|
||||
mv -f stamp-modobjs.tmp stamp-modobjs; \
|
||||
echo "Updated \`stamp-modobjs'."; \
|
||||
fi
|
||||
|
||||
modobjs: headers rm-modobjs-tmp
|
||||
.PHONY: modobjs
|
||||
|
||||
rm-modobjs-tmp:
|
||||
rm -f stamp-modobjs.tmp
|
||||
.PHONY: rm-modobjs-tmp
|
||||
|
||||
@CONFIG_MK@
|
||||
|
||||
Makemod: $(CONFIG_INCS) $(dir_top)/config.modules
|
||||
@case $(sdir_top) in \
|
||||
/*) top_srcdir=$(sdir_top) ;; \
|
||||
*) top_srcdir=$(subdir)/$(sdir_top) ;; \
|
||||
esac; \
|
||||
export top_srcdir; \
|
||||
echo 'cd $(dir_top) && $(SHELL)' \
|
||||
'$$top_srcdir/$(subdir)/mkmakemod.sh $(subdir) Makemod'; \
|
||||
cd $(dir_top) && \
|
||||
$(SHELL) $$top_srcdir/$(subdir)/mkmakemod.sh $(subdir) Makemod
|
||||
prep: Makemod
|
||||
@$(MAKE) -f Makemod $(MAKEDEFS) prep || rm -f Makemod
|
||||
.PHONY: prep
|
||||
|
||||
FORCE:
|
||||
.PHONY: FORCE
|
||||
|
||||
# ========== LINKING IN MODULES ==========
|
||||
|
||||
mymods.conf:
|
||||
@echo Linking with the standard modules.
|
||||
|
||||
modules: $(@E@NTRYOBJ)
|
||||
|
||||
$(ENTRYOBJ): FORCE
|
||||
@$(MAKE) -f Makemod $(MAKEDEFS) $@
|
||||
|
||||
# ========== DEPENDENCIES FOR CLEANUP ==========
|
||||
|
||||
# Since module cleanup rules depend on Makemod, they come first. This
|
||||
# forces module stuff to get cleaned before Makemod itself gets
|
||||
# deleted.
|
||||
|
||||
mostlyclean-here:
|
||||
rm -f stamp-modobjs stamp-modobjs.tmp
|
||||
.PHONY: mostlyclean-here
|
||||
|
||||
clean-here:
|
||||
rm -f modules.stamp zsh$(EXEEXT)
|
||||
rm -f libzsh-*.$(DL_EXT)
|
||||
.PHONY: clean-here
|
||||
|
||||
distclean-here:
|
||||
rm -f TAGS tags
|
||||
rm -f Makefile
|
||||
.PHONY: distclean-here
|
||||
|
||||
mostlyclean: mostlyclean-modules
|
||||
clean: clean-modules
|
||||
distclean: distclean-modules
|
||||
realclean: realclean-modules
|
||||
.PHONY: mostlyclean clean distclean realclean
|
||||
|
||||
# Don't remake Makemod just to delete things, even if it doesn't exist.
|
||||
mostlyclean-modules clean-modules distclean-modules realclean-modules:
|
||||
if test -f Makemod; then \
|
||||
$(MAKE) -f Makemod $(MAKEDEFS) `echo $@ | sed 's/-modules//'`; \
|
||||
fi; \
|
||||
exit 0
|
||||
.PHONY: mostlyclean-modules clean-modules distclean-modules \
|
||||
realclean-modules
|
||||
|
||||
@CLEAN_MK@
|
||||
|
||||
# ========== RECURSIVE MAKES ==========
|
||||
|
||||
modobjs modules headers proto zsh.export: Makemod
|
||||
@$(MAKE) -f Makemod $(MAKEDEFS) $@
|
||||
.PHONY: headers proto
|
192
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/Makemod.in.in
vendored
Normal file
192
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/Makemod.in.in
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
#
|
||||
# Makemod.in.in
|
||||
#
|
||||
# Copyright (c) 1995-1997 Richard Coleman
|
||||
# All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, without written agreement and without
|
||||
# license or royalty fees, to use, copy, modify, and distribute this
|
||||
# software and to distribute modified versions of this software for any
|
||||
# purpose, provided that the above copyright notice and the following
|
||||
# two paragraphs appear in all copies of this software.
|
||||
#
|
||||
# In no event shall Richard Coleman or the Zsh Development Group be liable
|
||||
# to any party for direct, indirect, special, incidental, or consequential
|
||||
# damages arising out of the use of this software and its documentation,
|
||||
# even if Richard Coleman and the Zsh Development Group have been advised of
|
||||
# the possibility of such damage.
|
||||
#
|
||||
# Richard Coleman and the Zsh Development Group specifically disclaim any
|
||||
# warranties, including, but not limited to, the implied warranties of
|
||||
# merchantability and fitness for a particular purpose. The software
|
||||
# provided hereunder is on an "as is" basis, and Richard Coleman and the
|
||||
# Zsh Development Group have no obligation to provide maintenance,
|
||||
# support, updates, enhancements, or modifications.
|
||||
#
|
||||
|
||||
# ========== OVERRIDABLE VARIABLES ==========
|
||||
|
||||
# subdir is done by mkmakemod.sh
|
||||
# dir_top is done by mkmakemod.sh
|
||||
# SUBDIRS is done by mkmakemod.sh
|
||||
|
||||
@VERSION_MK@
|
||||
|
||||
# source/build directories
|
||||
VPATH = @srcdir@
|
||||
sdir = @srcdir@
|
||||
sdir_top = @top_srcdir@
|
||||
INSTALL = @INSTALL@
|
||||
|
||||
@DEFS_MK@
|
||||
|
||||
sdir_src = $(sdir_top)/Src
|
||||
dir_src = $(dir_top)/Src
|
||||
|
||||
# ========== COMPILATION RULES ==========
|
||||
|
||||
DNCFLAGS =
|
||||
|
||||
COMPILE = $(CC) -c -I. -I$(dir_top)/Src -I$(sdir_top)/Src -I$(sdir_top)/Src/Zle -I$(sdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(D@L@CFLAGS)
|
||||
DLCOMPILE = $(CC) -c -I. -I$(dir_top)/Src -I$(sdir_top)/Src -I$(sdir_top)/Src/Zle -I$(sdir) $(CPPFLAGS) $(DEFS) -DMODULE $(CFLAGS) $(DLCFLAGS)
|
||||
LINK = $(CC) $(LDFLAGS) $(EXELDFLAGS) $(EXTRA_LDFLAGS) -o $@
|
||||
DLLINK = $(DLLD) $(LDFLAGS) $(LIBLDFLAGS) $(DLLDFLAGS) -o $@
|
||||
|
||||
KNR_OBJ=.o
|
||||
KNROBJ=._foo_
|
||||
|
||||
ANSIOBJ=.o
|
||||
ANSI_OBJ=._foo_
|
||||
|
||||
.SUFFIXES: .c .$(DL_EXT) ..o .._foo_ .o ._foo_ .syms .pro .epro
|
||||
|
||||
.c$(ANSI@U@OBJ):
|
||||
$(COMPILE) -o $@ $<
|
||||
@rm -f $(dir_src)/stamp-modobjs
|
||||
|
||||
.c$(KNR@U@OBJ):
|
||||
@ANSI2KNR@ $< > $@.c
|
||||
$(COMPILE) -o $@ $@.c
|
||||
rm -f $@.c
|
||||
@rm -f $(dir_src)/stamp-modobjs
|
||||
|
||||
.c.$(ANSI@U@OBJ):
|
||||
$(DLCOMPILE) -o $@ $<
|
||||
|
||||
.c.$(KNR@U@OBJ):
|
||||
@ANSI2KNR@ $< > $@.c
|
||||
$(DLCOMPILE) -o $@ $@.c
|
||||
rm -f $@.c
|
||||
|
||||
.c.syms:
|
||||
$(AWK) -f $(sdir_src)/makepro.awk $< $(subdir) > $@
|
||||
|
||||
.syms.epro:
|
||||
(echo '/* Generated automatically */'; sed -n '/^E/{s/^E//;p;}' < $<) \
|
||||
> $@
|
||||
(echo '/* Generated automatically */'; sed -n '/^L/{s/^L//;p;}' < $<) \
|
||||
> `echo $@ | sed 's/\.epro$$/.pro/'`
|
||||
|
||||
PROTODEPS = $(sdir_src)/makepro.awk
|
||||
|
||||
# ========== DEPENDENCIES FOR BUILDING ==========
|
||||
|
||||
all: modobjs modules
|
||||
.PHONY: all
|
||||
|
||||
modobjs: $(MODOBJS)
|
||||
modules: $(MODULES)
|
||||
headers: $(MDHS)
|
||||
proto: $(PROTOS)
|
||||
.PHONY: modobjs modules headers proto
|
||||
|
||||
prep:
|
||||
@case $(sdir_top) in \
|
||||
/*) top_srcdir=$(sdir_top) ;; \
|
||||
*) top_srcdir=$(subdir)/$(sdir_top) ;; \
|
||||
esac; \
|
||||
export top_srcdir; \
|
||||
cd $(dir_top) || exit 1; \
|
||||
subdirs='$(SUBDIRS)'; \
|
||||
for subdir in $$subdirs; do \
|
||||
dir=$(subdir)/$$subdir; \
|
||||
test -d $$dir || mkdir $$dir; \
|
||||
$(SHELL) $$top_srcdir/Src/mkmakemod.sh $$dir Makefile || exit 1; \
|
||||
( cd $$dir && $(MAKE) $(MAKEDEFS) $@ ) || exit 1; \
|
||||
done
|
||||
.PHONY: prep
|
||||
|
||||
headers: $(dir_src)/modules.stamp
|
||||
$(dir_src)/modules.stamp: $(MDDS)
|
||||
$(MAKE) -f $(makefile) $(MAKEDEFS) prep
|
||||
echo 'timestamp for *.mdd files' > $@
|
||||
.PHONY: headers
|
||||
|
||||
FORCE:
|
||||
.PHONY: FORCE
|
||||
|
||||
# ========== DEPENDENCIES FOR INSTALLING ==========
|
||||
|
||||
install: install.bin install.modules
|
||||
uninstall: uninstall.bin uninstall.modules
|
||||
.PHONY: install uninstall
|
||||
|
||||
install.bin: install.bin-here
|
||||
uninstall.bin: uninstall.bin-here
|
||||
install.modules: install.modules-here
|
||||
uninstall.modules: uninstall.modules-here
|
||||
.PHONY: install.bin uninstall.bin install.modules uninstall.modules
|
||||
|
||||
install.bin-here uninstall.bin-here:
|
||||
install.modules-here uninstall.modules-here:
|
||||
.PHONY: install.bin-here install.modules-here
|
||||
|
||||
# ========== DEPENDENCIES FOR CLEANUP ==========
|
||||
|
||||
@CLEAN_MK@
|
||||
|
||||
mostlyclean-here:
|
||||
rm -f *.o *.export *.$(DL_EXT)
|
||||
.PHONY: mostlyclean-here
|
||||
|
||||
clean-here:
|
||||
rm -f *.o.c *.syms *.pro *.epro *.mdh *.mdhi *.mdhs *.mdh.tmp
|
||||
.PHONY: clean-here
|
||||
|
||||
distclean-here:
|
||||
rm -f $(makefile) $(makefile).in
|
||||
.PHONY: distclean-here
|
||||
|
||||
# ========== RECURSIVE MAKES ==========
|
||||
|
||||
install.bin uninstall.bin install.modules uninstall.modules \
|
||||
modobjs modules headers proto:
|
||||
@subdirs='$(SUBDIRS)'; for subdir in $$subdirs; do \
|
||||
( cd $$subdir && $(MAKE) $(MAKEDEFS) $@ ) || exit 1; \
|
||||
done
|
||||
|
||||
# ========== DEPENDENCIES FOR MAINTENANCE ==========
|
||||
|
||||
$(makefile): $(makefile).in $(dir_top)/config.status
|
||||
@case $(sdir_top) in \
|
||||
/*) top_srcdir=$(sdir_top) ;; \
|
||||
*) top_srcdir=$(subdir)/$(sdir_top) ;; \
|
||||
esac; \
|
||||
export top_srcdir; \
|
||||
echo 'cd $(dir_top) && $(SHELL)' \
|
||||
'$$top_srcdir/Src/mkmakemod.sh -m $(subdir) $(makefile)'; \
|
||||
cd $(dir_top) && \
|
||||
$(SHELL) $$top_srcdir/Src/mkmakemod.sh -m $(subdir) $(makefile)
|
||||
|
||||
$(makefile).in: $(sdir_src)/mkmakemod.sh $(sdir_src)/Makemod.in.in $(MDDS) \
|
||||
$(dir_top)/config.modules
|
||||
@case $(sdir_top) in \
|
||||
/*) top_srcdir=$(sdir_top) ;; \
|
||||
*) top_srcdir=$(subdir)/$(sdir_top) ;; \
|
||||
esac; \
|
||||
export top_srcdir; \
|
||||
echo 'cd $(dir_top) && $(SHELL)' \
|
||||
'$$top_srcdir/Src/mkmakemod.sh -i $(subdir) $(makefile)'; \
|
||||
cd $(dir_top) && \
|
||||
$(SHELL) $$top_srcdir/Src/mkmakemod.sh -i $(subdir) $(makefile)
|
||||
|
18
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/aloxaf/.cvsignore
vendored
Normal file
18
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/aloxaf/.cvsignore
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
*.export
|
||||
so_locations
|
||||
*.pro
|
||||
*.epro
|
||||
*.syms
|
||||
*.o
|
||||
*.o.c
|
||||
*.so
|
||||
*.mdh
|
||||
*.mdhi
|
||||
*.mdhs
|
||||
*.mdh.tmp
|
||||
*.swp
|
||||
errnames.c errcount.h
|
||||
*.dll
|
||||
curses_keys.h
|
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/aloxaf/.distfiles
vendored
Normal file
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/aloxaf/.distfiles
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
DISTFILES_SRC='
|
||||
'
|
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/aloxaf/.exrc
vendored
Normal file
2
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/aloxaf/.exrc
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
set ai
|
||||
set sw=4
|
8
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/aloxaf/.gitignore
vendored
Normal file
8
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/aloxaf/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
Makefile.in
|
||||
*.epro
|
||||
*.export
|
||||
*.mdh
|
||||
*.mdhi
|
||||
*.mdhs
|
||||
*.pro
|
||||
*.syms
|
@ -0,0 +1,543 @@
|
||||
#include "fzftab.mdh"
|
||||
#include "fzftab.pro"
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char* get_color(char* file, const struct stat* sb);
|
||||
const char* get_suffix(char* file, const struct stat* sb);
|
||||
const char* colorize_from_mode(char* file, const struct stat* sb);
|
||||
const char* colorize_from_name(char* file);
|
||||
char** fzf_tab_colorize(char* file);
|
||||
int compile_patterns(char* nam, char** list_colors);
|
||||
char* ftb_strcat(char* dst, int n, ...);
|
||||
|
||||
/* Indixes into the terminal string arrays. */
|
||||
#define COL_NO 0
|
||||
#define COL_FI 1
|
||||
#define COL_DI 2
|
||||
#define COL_LN 3
|
||||
#define COL_PI 4
|
||||
#define COL_SO 5
|
||||
#define COL_BD 6
|
||||
#define COL_CD 7
|
||||
#define COL_OR 8
|
||||
#define COL_MI 9
|
||||
#define COL_SU 10
|
||||
#define COL_SG 11
|
||||
#define COL_TW 12
|
||||
#define COL_OW 13
|
||||
#define COL_ST 14
|
||||
#define COL_EX 15
|
||||
#define COL_LC 16
|
||||
#define COL_RC 17
|
||||
#define COL_EC 18
|
||||
#define COL_TC 19
|
||||
#define COL_SP 20
|
||||
#define COL_MA 21
|
||||
#define COL_HI 22
|
||||
#define COL_DU 23
|
||||
#define COL_SA 24
|
||||
|
||||
#define NUM_COLS 25
|
||||
|
||||
/* Names of the terminal strings. */
|
||||
static char* colnames[] = { "no", "fi", "di", "ln", "pi", "so", "bd", "cd", "or", "mi", "su", "sg",
|
||||
"tw", "ow", "st", "ex", "lc", "rc", "ec", "tc", "sp", "ma", "hi", "du", "sa", NULL };
|
||||
|
||||
/* Default values. */
|
||||
static char* defcols[]
|
||||
= { "0", "0", "1;31", "1;36", "33", "1;35", "1;33", "1;33", NULL, NULL, "37;41", "30;43",
|
||||
"30;42", "34;42", "37;44", "1;32", "\033[", "m", NULL, "0", "0", "7", NULL, NULL, "0" };
|
||||
|
||||
static char* fzf_tab_module_version;
|
||||
|
||||
struct pattern {
|
||||
Patprog pat;
|
||||
char color[50];
|
||||
};
|
||||
|
||||
static int opt_list_type = OPT_INVALID;
|
||||
static int pat_cnt = 0;
|
||||
static struct pattern* name_color = NULL;
|
||||
static char mode_color[NUM_COLS][20];
|
||||
|
||||
// TODO: use ZLS_COLORS ?
|
||||
int compile_patterns(char* nam, char** list_colors)
|
||||
{
|
||||
// clean old name_color and set pat_cnt = 0
|
||||
if (pat_cnt != 0) {
|
||||
while (--pat_cnt) {
|
||||
freepatprog(name_color[pat_cnt].pat);
|
||||
}
|
||||
free(name_color);
|
||||
}
|
||||
// initialize mode_color with default value
|
||||
for (int i = 0; i < NUM_COLS; i++) {
|
||||
if (defcols[i]) {
|
||||
strcpy(mode_color[i], defcols[i]);
|
||||
}
|
||||
}
|
||||
// empty array, just return
|
||||
if (list_colors == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// how many pattens?
|
||||
while (list_colors[pat_cnt] != NULL) {
|
||||
pat_cnt++;
|
||||
}
|
||||
name_color = zshcalloc(pat_cnt * sizeof(struct pattern));
|
||||
|
||||
for (int i = 0; i < pat_cnt; i++) {
|
||||
char* pat = ztrdup(list_colors[i]);
|
||||
char* color = strrchr(pat, '=');
|
||||
if (color == NULL)
|
||||
continue;
|
||||
*color = '\0';
|
||||
tokenize(pat);
|
||||
remnulargs(pat);
|
||||
|
||||
// mode=color
|
||||
bool skip = false;
|
||||
for (int j = 0; j < NUM_COLS; j++) {
|
||||
if (strpfx(colnames[j], list_colors[i])) {
|
||||
strcpy(mode_color[j], color + 1);
|
||||
name_color[i].pat = NULL;
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
if (skip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// name=color
|
||||
if (!(name_color[i].pat = patcompile(pat, PAT_ZDUP, NULL))) {
|
||||
zwarnnam(nam, "bad pattern: %s", list_colors[i]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
strcpy(name_color[i].color, color + 1);
|
||||
free(pat);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: use zsh mod_export function `file_type` ?
|
||||
const char* get_suffix(char* file, const struct stat* sb)
|
||||
{
|
||||
struct stat sb2;
|
||||
mode_t filemode = sb->st_mode;
|
||||
|
||||
if (S_ISBLK(filemode))
|
||||
return "#";
|
||||
else if (S_ISCHR(filemode))
|
||||
return "%";
|
||||
else if (S_ISDIR(filemode))
|
||||
return "/";
|
||||
else if (S_ISFIFO(filemode))
|
||||
return "|";
|
||||
else if (S_ISLNK(filemode))
|
||||
if (strpfx(mode_color[COL_LN], "target")) {
|
||||
if (stat(file, &sb2) == -1) {
|
||||
return "@";
|
||||
}
|
||||
return get_suffix(file, &sb2);
|
||||
} else {
|
||||
return "@";
|
||||
}
|
||||
else if (S_ISREG(filemode))
|
||||
return (filemode & S_IXUGO) ? "*" : "";
|
||||
else if (S_ISSOCK(filemode))
|
||||
return "=";
|
||||
else
|
||||
return "?";
|
||||
}
|
||||
|
||||
const char* get_color(char* file, const struct stat* sb)
|
||||
{
|
||||
// no list-colors, return empty color
|
||||
if (pat_cnt == 0) {
|
||||
return "";
|
||||
}
|
||||
const char* ret;
|
||||
if ((ret = colorize_from_mode(file, sb)) || (ret = colorize_from_name(file))) {
|
||||
return ret;
|
||||
}
|
||||
return mode_color[COL_FI];
|
||||
}
|
||||
|
||||
const char* colorize_from_name(char* file)
|
||||
{
|
||||
for (int i = 0; i < pat_cnt; i++) {
|
||||
if (name_color && name_color[i].pat && pattry(name_color[i].pat, file)) {
|
||||
return name_color[i].color;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* colorize_from_mode(char* file, const struct stat* sb)
|
||||
{
|
||||
struct stat sb2;
|
||||
|
||||
switch (sb->st_mode & S_IFMT) {
|
||||
case S_IFDIR:
|
||||
return mode_color[COL_DI];
|
||||
case S_IFLNK: {
|
||||
if (strpfx(mode_color[COL_LN], "target")) {
|
||||
if (stat(file, &sb2) == -1) {
|
||||
return mode_color[COL_OR];
|
||||
}
|
||||
return get_color(file, &sb2);
|
||||
}
|
||||
}
|
||||
case S_IFIFO:
|
||||
return mode_color[COL_PI];
|
||||
case S_IFSOCK:
|
||||
return mode_color[COL_SO];
|
||||
case S_IFBLK:
|
||||
return mode_color[COL_BD];
|
||||
case S_IFCHR:
|
||||
return mode_color[COL_CD];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (sb->st_mode & S_ISUID) {
|
||||
return mode_color[COL_SU];
|
||||
} else if (sb->st_mode & S_ISGID) {
|
||||
return mode_color[COL_SG];
|
||||
// tw ow st ??
|
||||
} else if (sb->st_mode & S_IXUSR) {
|
||||
return mode_color[COL_EX];
|
||||
}
|
||||
|
||||
/* Check for suffix alias */
|
||||
size_t len = strlen(file);
|
||||
/* shortest valid suffix format is a.b */
|
||||
if (len > 2) {
|
||||
const char* suf = file + len - 1;
|
||||
while (suf > file + 1) {
|
||||
if (suf[-1] == '.') {
|
||||
if (sufaliastab->getnode(sufaliastab, suf)) {
|
||||
return mode_color[COL_SA];
|
||||
}
|
||||
break;
|
||||
}
|
||||
suf--;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct {
|
||||
char** array;
|
||||
size_t len;
|
||||
size_t size;
|
||||
} ftb_compcap;
|
||||
|
||||
// Usage:
|
||||
// initialize fzf-tab-generate-compcap -i
|
||||
// output to _ftb_compcap fzf-tab-generate-compcap -o
|
||||
// add a entry fzf-tab-generate-compcap word desc opts
|
||||
static int bin_fzf_tab_compcap_generate(char* nam, char** args, Options ops, UNUSED(int func))
|
||||
{
|
||||
if (OPT_ISSET(ops, 'o')) {
|
||||
// write final result to _ftb_compcap
|
||||
setaparam("_ftb_compcap", ftb_compcap.array);
|
||||
ftb_compcap.array = NULL;
|
||||
return 0;
|
||||
} else if (OPT_ISSET(ops, 'i')) {
|
||||
// init
|
||||
if (ftb_compcap.array)
|
||||
freearray(ftb_compcap.array);
|
||||
ftb_compcap.array = zshcalloc(1024 * sizeof(char*));
|
||||
ftb_compcap.len = 0, ftb_compcap.size = 1024;
|
||||
return 0;
|
||||
}
|
||||
if (ftb_compcap.array == NULL) {
|
||||
zwarnnam(nam, "please initialize it first");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get paramaters
|
||||
char **words = getaparam(args[0]), **dscrs = getaparam(args[1]), *opts = getsparam(args[2]);
|
||||
if (!words || !dscrs || !opts) {
|
||||
zwarnnam(nam, "wrong argument");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *bs = metafy("\2", 1, META_DUP), *nul = metafy("\0word\0", 6, META_DUP);
|
||||
size_t dscrs_cnt = arrlen(dscrs);
|
||||
|
||||
for (int i = 0; words[i]; i++) {
|
||||
// TODO: replace '\n'
|
||||
char* buffer = zshcalloc(256 * sizeof(char));
|
||||
char* dscr = i < dscrs_cnt ? dscrs[i] : words[i];
|
||||
|
||||
buffer = ftb_strcat(buffer, 5, dscr, bs, opts, nul, words[i]);
|
||||
ftb_compcap.array[ftb_compcap.len++] = buffer;
|
||||
|
||||
if (ftb_compcap.len == ftb_compcap.size) {
|
||||
ftb_compcap.array
|
||||
= zrealloc(ftb_compcap.array, (1024 + ftb_compcap.size) * sizeof(char*));
|
||||
ftb_compcap.size += 1024;
|
||||
memset(ftb_compcap.array + ftb_compcap.size - 1024, 0, 1024 * sizeof(char*));
|
||||
}
|
||||
}
|
||||
|
||||
zsfree(bs);
|
||||
zsfree(nul);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cat n string, return the pointer to the new string
|
||||
// `size` is the size of dst
|
||||
// dst will be reallocated if is not big enough
|
||||
char* ftb_strcat(char* dst, int n, ...)
|
||||
{
|
||||
va_list valist;
|
||||
va_start(valist, n);
|
||||
|
||||
char* final = zrealloc(dst, 128);
|
||||
size_t size = 128, max_len = 128 - 1;
|
||||
dst = final;
|
||||
|
||||
for (int i = 0, idx = 0; i < n; i++) {
|
||||
char* src = va_arg(valist, char*);
|
||||
for (; *src != '\0'; dst++, src++, idx++) {
|
||||
if (idx == max_len) {
|
||||
size += size / 2;
|
||||
final = zrealloc(final, size);
|
||||
max_len = size - 1;
|
||||
dst = &final[idx];
|
||||
}
|
||||
*dst = *src;
|
||||
}
|
||||
}
|
||||
*dst = '\0';
|
||||
va_end(valist);
|
||||
|
||||
return final;
|
||||
}
|
||||
|
||||
// accept an
|
||||
char** fzf_tab_colorize(char* file)
|
||||
{
|
||||
// TODO: can avoid so many zalloc here?
|
||||
file = unmeta(file);
|
||||
|
||||
struct stat sb;
|
||||
if (lstat(file, &sb) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* suffix = "";
|
||||
if (isset(opt_list_type)) {
|
||||
suffix = get_suffix(file, &sb);
|
||||
}
|
||||
const char* color = get_color(file, &sb);
|
||||
|
||||
char* symlink = "";
|
||||
const char* symcolor = "";
|
||||
if ((sb.st_mode & S_IFMT) == S_IFLNK) {
|
||||
symlink = zalloc(PATH_MAX);
|
||||
int end = readlink(file, symlink, PATH_MAX);
|
||||
symlink[end] = '\0';
|
||||
if (stat(file, &sb) == -1) {
|
||||
symcolor = mode_color[COL_OR];
|
||||
} else {
|
||||
char tmp[PATH_MAX];
|
||||
realpath(file, tmp);
|
||||
symcolor = get_color(file, &sb);
|
||||
}
|
||||
}
|
||||
|
||||
char** reply = zshcalloc((4 + 1) * sizeof(char*));
|
||||
|
||||
if (strlen(color) != 0) {
|
||||
reply[0] = zalloc(128);
|
||||
reply[1] = zalloc(128);
|
||||
sprintf(reply[0], "%s%s%s", mode_color[COL_LC], color, mode_color[COL_RC]);
|
||||
sprintf(reply[1], "%s%s%s", mode_color[COL_LC], "0", mode_color[COL_RC]);
|
||||
} else {
|
||||
reply[0] = ztrdup("");
|
||||
reply[1] = ztrdup("");
|
||||
}
|
||||
|
||||
reply[2] = ztrdup(suffix);
|
||||
|
||||
if (symlink[0] != '\0') {
|
||||
reply[3] = zalloc(PATH_MAX);
|
||||
sprintf(reply[3], "%s%s%s%s%s%s%s", mode_color[COL_LC], symcolor, mode_color[COL_RC],
|
||||
symlink, mode_color[COL_LC], "0", mode_color[COL_RC]);
|
||||
free(symlink);
|
||||
} else {
|
||||
reply[3] = ztrdup("");
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
reply[i] = metafy(reply[i], -1, META_REALLOC);
|
||||
}
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static int bin_fzf_tab_candidates_generate(char* nam, char** args, Options ops, UNUSED(int func))
|
||||
{
|
||||
if (OPT_ISSET(ops, 'i')) {
|
||||
// compile list_colors pattern
|
||||
if (*args == NULL) {
|
||||
zwarnnam(nam, "please specify an array");
|
||||
return 1;
|
||||
} else {
|
||||
char** array = getaparam(*args);
|
||||
return compile_patterns(nam, array);
|
||||
}
|
||||
}
|
||||
|
||||
char **ftb_compcap = getaparam("_ftb_compcap"), **group_colors = getaparam("group_colors"),
|
||||
*default_color = getsparam("default_color"), *prefix = getsparam("prefix");
|
||||
|
||||
size_t group_colors_len = arrlen(group_colors);
|
||||
size_t ftb_compcap_len = arrlen(ftb_compcap);
|
||||
|
||||
char *bs = metafy("\b", 1, META_DUP), *nul = metafy("\0", 1, META_DUP),
|
||||
*soh = metafy("\2", 1, META_DUP);
|
||||
|
||||
char **candidates = zshcalloc(sizeof(char*) * (ftb_compcap_len + 1)),
|
||||
*filepath = zshcalloc(PATH_MAX * sizeof(char)), *dpre = zshcalloc(128),
|
||||
*dsuf = zshcalloc(128);
|
||||
|
||||
char* first_word = zshcalloc(512 * sizeof(char));
|
||||
int same_word = 1;
|
||||
|
||||
for (int i = 0; i < ftb_compcap_len; i++) {
|
||||
char *word = "", *group = NULL, *realdir = NULL;
|
||||
strcpy(dpre, "");
|
||||
strcpy(dsuf, "");
|
||||
|
||||
// extract all the variables what we need
|
||||
char** compcap = sepsplit(ftb_compcap[i], soh, 1, 0);
|
||||
char* desc = compcap[0];
|
||||
char** info = sepsplit(compcap[1], nul, 1, 0);
|
||||
|
||||
for (int j = 0; info[j]; j += 2) {
|
||||
if (!strcmp(info[j], "word")) {
|
||||
word = info[j + 1];
|
||||
// unquote word
|
||||
parse_subst_string(word);
|
||||
remnulargs(word);
|
||||
untokenize(word);
|
||||
} else if (!strcmp(info[j], "group")) {
|
||||
group = info[j + 1];
|
||||
} else if (!strcmp(info[j], "realdir")) {
|
||||
realdir = info[j + 1];
|
||||
}
|
||||
}
|
||||
|
||||
// check if all the words are the same
|
||||
if (i == 0) {
|
||||
first_word = ftb_strcat(first_word, 1, word);
|
||||
} else if (same_word && strcmp(word, first_word) != 0) {
|
||||
same_word = 0;
|
||||
}
|
||||
|
||||
// add character and color to describe the type of the files
|
||||
if (realdir) {
|
||||
filepath = ftb_strcat(filepath, 2, realdir, word);
|
||||
char** reply = fzf_tab_colorize(filepath);
|
||||
if (reply != NULL) {
|
||||
dpre = ftb_strcat(dpre, 2, reply[1], reply[0]);
|
||||
if (reply[3][0] != '\0') {
|
||||
dsuf = ftb_strcat(dsuf, 4, reply[1], reply[2], " -> ", reply[3]);
|
||||
} else {
|
||||
dsuf = ftb_strcat(dsuf, 2, reply[1], reply[2]);
|
||||
}
|
||||
if (dpre[0] != '\0') {
|
||||
setiparam("colorful", 1);
|
||||
}
|
||||
freearray(reply);
|
||||
}
|
||||
}
|
||||
|
||||
char* result = zshcalloc(256 * sizeof(char));
|
||||
|
||||
// add color to description if they have group index
|
||||
if (group) {
|
||||
// use strtol ?
|
||||
int group_index = atoi(group);
|
||||
char* color = group_index >= group_colors_len ? "" : group_colors[group_index - 1];
|
||||
// add prefix
|
||||
result = ftb_strcat(
|
||||
result, 11, group, bs, color, prefix, dpre, nul, group, bs, desc, nul, dsuf);
|
||||
} else {
|
||||
result = ftb_strcat(result, 6, default_color, dpre, nul, desc, nul, dsuf);
|
||||
}
|
||||
// quotedzputs(result, stdout);
|
||||
// putchar('\n');
|
||||
candidates[i] = result;
|
||||
|
||||
freearray(info);
|
||||
freearray(compcap);
|
||||
}
|
||||
|
||||
setaparam("tcandidates", candidates);
|
||||
setiparam("same_word", same_word);
|
||||
zsfree(dpre);
|
||||
zsfree(dsuf);
|
||||
zsfree(filepath);
|
||||
zsfree(first_word);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct builtin bintab[] = {
|
||||
BUILTIN("fzf-tab-compcap-generate", 0, bin_fzf_tab_compcap_generate, 0, -1, 0, "io", NULL),
|
||||
BUILTIN("fzf-tab-candidates-generate", 0, bin_fzf_tab_candidates_generate, 0, -1, 0, "i", NULL),
|
||||
};
|
||||
|
||||
static struct paramdef patab[] = {
|
||||
STRPARAMDEF("FZF_TAB_MODULE_VERSION", &fzf_tab_module_version),
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
static struct features module_features = {
|
||||
bintab, sizeof(bintab) / sizeof(*bintab),
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
patab, sizeof(patab) / sizeof(*patab),
|
||||
0,
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
int setup_(UNUSED(Module m)) { return 0; }
|
||||
|
||||
int features_(Module m, char*** features)
|
||||
{
|
||||
*features = featuresarray(m, &module_features);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int enables_(Module m, int** enables) { return handlefeatures(m, &module_features, enables); }
|
||||
|
||||
int boot_(UNUSED(Module m))
|
||||
{
|
||||
fzf_tab_module_version = ztrdup("0.2.2");
|
||||
// different zsh version may have different value of list_type's index
|
||||
// so query it dynamically
|
||||
opt_list_type = optlookup("list_types");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cleanup_(UNUSED(Module m)) { return setfeatureenables(m, &module_features, NULL); }
|
||||
|
||||
int finish_(UNUSED(Module m))
|
||||
{
|
||||
printf("fzf-tab module unloaded.\n");
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
7
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/aloxaf/fzftab.mdd
vendored
Normal file
7
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/aloxaf/fzftab.mdd
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
name=aloxaf/fzftab
|
||||
link=dynamic
|
||||
load=no
|
||||
|
||||
autofeatures="b:fzf-tab-colorize p:FZF_TAB_MODULE_VERSION"
|
||||
|
||||
objects="fzftab.o"
|
7236
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/builtin.c
vendored
Normal file
7236
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/builtin.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
742
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/compat.c
vendored
Normal file
742
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/compat.c
vendored
Normal file
@ -0,0 +1,742 @@
|
||||
/*
|
||||
* compat.c - compatibility routines for the deprived
|
||||
*
|
||||
* This file is part of zsh, the Z shell.
|
||||
*
|
||||
* Copyright (c) 1992-1997 Paul Falstad
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and to distribute modified versions of this software for any
|
||||
* purpose, provided that the above copyright notice and the following
|
||||
* two paragraphs appear in all copies of this software.
|
||||
*
|
||||
* In no event shall Paul Falstad or the Zsh Development Group be liable
|
||||
* to any party for direct, indirect, special, incidental, or consequential
|
||||
* damages arising out of the use of this software and its documentation,
|
||||
* even if Paul Falstad and the Zsh Development Group have been advised of
|
||||
* the possibility of such damage.
|
||||
*
|
||||
* Paul Falstad and the Zsh Development Group specifically disclaim any
|
||||
* warranties, including, but not limited to, the implied warranties of
|
||||
* merchantability and fitness for a particular purpose. The software
|
||||
* provided hereunder is on an "as is" basis, and Paul Falstad and the
|
||||
* Zsh Development Group have no obligation to provide maintenance,
|
||||
* support, updates, enhancements, or modifications.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "zsh.mdh"
|
||||
#include "compat.pro"
|
||||
|
||||
/* Return pointer to first occurence of string t *
|
||||
* in string s. Return NULL if not present. */
|
||||
|
||||
/**/
|
||||
#ifndef HAVE_STRSTR
|
||||
|
||||
/**/
|
||||
char *
|
||||
strstr(const char *s, const char *t)
|
||||
{
|
||||
const char *p1, *p2;
|
||||
|
||||
for (; *s; s++) {
|
||||
for (p1 = s, p2 = t; *p2; p1++, p2++)
|
||||
if (*p1 != *p2)
|
||||
break;
|
||||
if (!*p2)
|
||||
return (char *)s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**/
|
||||
#endif
|
||||
|
||||
|
||||
/**/
|
||||
#ifndef HAVE_GETHOSTNAME
|
||||
|
||||
/**/
|
||||
int
|
||||
gethostname(char *name, size_t namelen)
|
||||
{
|
||||
struct utsname uts;
|
||||
|
||||
uname(&uts);
|
||||
if(strlen(uts.nodename) >= namelen) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
strcpy(name, uts.nodename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**/
|
||||
#endif
|
||||
|
||||
|
||||
/**/
|
||||
#ifndef HAVE_GETTIMEOFDAY
|
||||
|
||||
/**/
|
||||
int
|
||||
gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
tv->tv_usec = 0;
|
||||
tv->tv_sec = (long)time((time_t) 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**/
|
||||
#endif
|
||||
|
||||
|
||||
/* Provide clock time with nanoseconds */
|
||||
|
||||
/**/
|
||||
mod_export int
|
||||
zgettime(struct timespec *ts)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
struct timespec dts;
|
||||
if (clock_gettime(CLOCK_REALTIME, &dts) < 0) {
|
||||
zwarn("unable to retrieve time: %e", errno);
|
||||
ret--;
|
||||
} else {
|
||||
ret++;
|
||||
ts->tv_sec = (time_t) dts.tv_sec;
|
||||
ts->tv_nsec = (long) dts.tv_nsec;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ret) {
|
||||
struct timeval dtv;
|
||||
struct timezone dtz;
|
||||
gettimeofday(&dtv, &dtz);
|
||||
ret++;
|
||||
ts->tv_sec = (time_t) dtv.tv_sec;
|
||||
ts->tv_nsec = (long) dtv.tv_usec * 1000;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* compute the difference between two calendar times */
|
||||
|
||||
/**/
|
||||
#ifndef HAVE_DIFFTIME
|
||||
|
||||
/**/
|
||||
double
|
||||
difftime(time_t t2, time_t t1)
|
||||
{
|
||||
return ((double)t2 - (double)t1);
|
||||
}
|
||||
|
||||
/**/
|
||||
#endif
|
||||
|
||||
|
||||
/**/
|
||||
#ifndef HAVE_STRERROR
|
||||
extern char *sys_errlist[];
|
||||
|
||||
/* Get error message string associated with a particular *
|
||||
* error number, and returns a pointer to that string. *
|
||||
* This is not a particularly robust version of strerror. */
|
||||
|
||||
/**/
|
||||
char *
|
||||
strerror(int errnum)
|
||||
{
|
||||
return (sys_errlist[errnum]);
|
||||
}
|
||||
|
||||
/**/
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
/* pathconf(_PC_PATH_MAX) is not currently useful to zsh. The value *
|
||||
* returned varies depending on a number of factors, e.g. the amount *
|
||||
* of memory available to the operating system at a given time; thus *
|
||||
* it can't be used for buffer allocation, or even as an indication *
|
||||
* of whether an attempt to use or create a given pathname may fail *
|
||||
* at any future time. *
|
||||
* *
|
||||
* The call is also permitted to fail if the argument path is not an *
|
||||
* existing directory, so even to make sense of that one must search *
|
||||
* for a valid directory somewhere in the path and adjust. Even if *
|
||||
* it succeeds, the return value is relative to the input directory, *
|
||||
* and therefore potentially relative to the length of the shortest *
|
||||
* path either to that directory or to our working directory. *
|
||||
* *
|
||||
* Finally, see the note below for glibc; detection of pathconf() is *
|
||||
* not by itself an indication that it works reliably. */
|
||||
|
||||
/* The documentation for pathconf() says something like: *
|
||||
* The limit is returned, if one exists. If the system does *
|
||||
* not have a limit for the requested resource, -1 is *
|
||||
* returned, and errno is unchanged. If there is an error, *
|
||||
* -1 is returned, and errno is set to reflect the nature of *
|
||||
* the error. *
|
||||
* *
|
||||
* System calls are not permitted to set errno to 0; but we must (or *
|
||||
* some other flag value) in order to determine that the resource is *
|
||||
* unlimited. What use is leaving errno unchanged? Instead, define *
|
||||
* a wrapper that resets errno to 0 and returns 0 for "the system *
|
||||
* does not have a limit," so that -1 always means a real error. */
|
||||
|
||||
/**/
|
||||
mod_export long
|
||||
zpathmax(char *dir)
|
||||
{
|
||||
#ifdef HAVE_PATHCONF
|
||||
long pathmax;
|
||||
|
||||
errno = 0;
|
||||
if ((pathmax = pathconf(dir, _PC_PATH_MAX)) >= 0) {
|
||||
/* Some versions of glibc pathconf return a hardwired value! */
|
||||
return pathmax;
|
||||
} else if (errno == EINVAL || errno == ENOENT || errno == ENOTDIR) {
|
||||
/* Work backward to find a directory, until we run out of path. */
|
||||
char *tail = strrchr(dir, '/');
|
||||
while (tail > dir && tail[-1] == '/')
|
||||
--tail;
|
||||
if (tail > dir) {
|
||||
*tail = 0;
|
||||
pathmax = zpathmax(dir);
|
||||
*tail = '/';
|
||||
} else {
|
||||
errno = 0;
|
||||
if (tail)
|
||||
pathmax = pathconf("/", _PC_PATH_MAX);
|
||||
else
|
||||
pathmax = pathconf(".", _PC_PATH_MAX);
|
||||
}
|
||||
if (pathmax > 0) {
|
||||
long taillen = (tail ? strlen(tail) : (strlen(dir) + 1));
|
||||
if (taillen < pathmax)
|
||||
return pathmax - taillen;
|
||||
else
|
||||
errno = ENAMETOOLONG;
|
||||
}
|
||||
}
|
||||
if (errno)
|
||||
return -1;
|
||||
else
|
||||
return 0; /* pathmax should be considered unlimited */
|
||||
#else
|
||||
long dirlen = strlen(dir);
|
||||
|
||||
/* The following is wrong if dir is not an absolute path. */
|
||||
return ((long) ((dirlen >= PATH_MAX) ?
|
||||
((errno = ENAMETOOLONG), -1) :
|
||||
((errno = 0), PATH_MAX - dirlen)));
|
||||
#endif
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/**/
|
||||
#ifdef HAVE_SYSCONF
|
||||
/*
|
||||
* This is replaced by a macro from system.h if not HAVE_SYSCONF.
|
||||
* 0 is returned by sysconf if _SC_OPEN_MAX is unavailable;
|
||||
* -1 is returned on error
|
||||
*
|
||||
* Neither of these should happen, but resort to OPEN_MAX rather
|
||||
* than return 0 or -1 just in case.
|
||||
*
|
||||
* We'll limit the open maximum to ZSH_INITIAL_OPEN_MAX to
|
||||
* avoid probing ridiculous numbers of file descriptors.
|
||||
*/
|
||||
|
||||
/**/
|
||||
mod_export long
|
||||
zopenmax(void)
|
||||
{
|
||||
long openmax;
|
||||
|
||||
if ((openmax = sysconf(_SC_OPEN_MAX)) < 1) {
|
||||
openmax = OPEN_MAX;
|
||||
} else if (openmax > OPEN_MAX) {
|
||||
/* On some systems, "limit descriptors unlimited" or the *
|
||||
* equivalent will set openmax to a huge number. Unless *
|
||||
* there actually is a file descriptor > OPEN_MAX already *
|
||||
* open, nothing in zsh requires the true maximum, and in *
|
||||
* fact it causes inefficiency elsewhere if we report it. *
|
||||
* So, report the maximum of OPEN_MAX or the largest open *
|
||||
* descriptor (is there a better way to find that?). */
|
||||
long i, j = OPEN_MAX;
|
||||
if (openmax > ZSH_INITIAL_OPEN_MAX)
|
||||
openmax = ZSH_INITIAL_OPEN_MAX;
|
||||
for (i = j; i < openmax; i += (errno != EINTR)) {
|
||||
errno = 0;
|
||||
if (fcntl(i, F_GETFL, 0) < 0 &&
|
||||
(errno == EBADF || errno == EINTR))
|
||||
continue;
|
||||
j = i;
|
||||
}
|
||||
openmax = j;
|
||||
}
|
||||
|
||||
return (max_zsh_fd > openmax) ? max_zsh_fd : openmax;
|
||||
}
|
||||
|
||||
/**/
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Rationalise the current directory, returning the string.
|
||||
*
|
||||
* If "d" is not NULL, it is used to store information about the
|
||||
* directory. The returned name is also present in d->dirname and is in
|
||||
* permanently allocated memory. The handling of this case depends on
|
||||
* whether the fchdir() system call is available; if it is, it is assumed
|
||||
* the caller is able to restore the current directory. On successfully
|
||||
* identifying the directory the function returns immediately rather
|
||||
* than ascending the hierarchy.
|
||||
*
|
||||
* If "d" is NULL, no assumption about the caller's behaviour is
|
||||
* made. The returned string is in heap memory. This case is
|
||||
* always handled by changing directory up the hierarchy.
|
||||
*
|
||||
* On Cygwin or other systems where USE_GETCWD is defined (at the
|
||||
* time of writing only QNX), we skip all the above and use the
|
||||
* getcwd() system call.
|
||||
*/
|
||||
|
||||
/**/
|
||||
mod_export char *
|
||||
zgetdir(struct dirsav *d)
|
||||
{
|
||||
char nbuf[PATH_MAX+3];
|
||||
char *buf;
|
||||
int bufsiz, pos;
|
||||
struct stat sbuf;
|
||||
ino_t pino;
|
||||
dev_t pdev;
|
||||
#if !defined(__CYGWIN__) && !defined(USE_GETCWD)
|
||||
struct dirent *de;
|
||||
DIR *dir;
|
||||
dev_t dev;
|
||||
ino_t ino;
|
||||
int len;
|
||||
#endif
|
||||
|
||||
buf = zhalloc(bufsiz = PATH_MAX+1);
|
||||
pos = bufsiz - 1;
|
||||
buf[pos] = '\0';
|
||||
strcpy(nbuf, "../");
|
||||
if (stat(".", &sbuf) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Record the initial inode and device */
|
||||
pino = sbuf.st_ino;
|
||||
pdev = sbuf.st_dev;
|
||||
if (d)
|
||||
d->ino = pino, d->dev = pdev;
|
||||
#if !defined(__CYGWIN__) && !defined(USE_GETCWD)
|
||||
#ifdef HAVE_FCHDIR
|
||||
else
|
||||
#endif
|
||||
holdintr();
|
||||
|
||||
for (;;) {
|
||||
/* Examine the parent of the current directory. */
|
||||
if (stat("..", &sbuf) < 0)
|
||||
break;
|
||||
|
||||
/* Inode and device of curtent directory */
|
||||
ino = pino;
|
||||
dev = pdev;
|
||||
/* Inode and device of current directory's parent */
|
||||
pino = sbuf.st_ino;
|
||||
pdev = sbuf.st_dev;
|
||||
|
||||
/* If they're the same, we've reached the root directory. */
|
||||
if (ino == pino && dev == pdev) {
|
||||
if (!buf[pos])
|
||||
buf[--pos] = '/';
|
||||
if (d) {
|
||||
#ifndef HAVE_FCHDIR
|
||||
zchdir(buf + pos);
|
||||
noholdintr();
|
||||
#endif
|
||||
return d->dirname = ztrdup(buf + pos);
|
||||
}
|
||||
zchdir(buf + pos);
|
||||
noholdintr();
|
||||
return buf + pos;
|
||||
}
|
||||
|
||||
/* Search the parent for the current directory. */
|
||||
if (!(dir = opendir("..")))
|
||||
break;
|
||||
|
||||
while ((de = readdir(dir))) {
|
||||
char *fn = de->d_name;
|
||||
/* Ignore `.' and `..'. */
|
||||
if (fn[0] == '.' &&
|
||||
(fn[1] == '\0' ||
|
||||
(fn[1] == '.' && fn[2] == '\0')))
|
||||
continue;
|
||||
#ifdef HAVE_STRUCT_DIRENT_D_STAT
|
||||
if(de->d_stat.st_dev == dev && de->d_stat.st_ino == ino) {
|
||||
/* Found the directory we're currently in */
|
||||
strncpy(nbuf + 3, fn, PATH_MAX);
|
||||
break;
|
||||
}
|
||||
#else /* !HAVE_STRUCT_DIRENT_D_STAT */
|
||||
# ifdef HAVE_STRUCT_DIRENT_D_INO
|
||||
if (dev != pdev || (ino_t) de->d_ino == ino)
|
||||
# endif /* HAVE_STRUCT_DIRENT_D_INO */
|
||||
{
|
||||
/* Maybe found directory, need to check device & inode */
|
||||
strncpy(nbuf + 3, fn, PATH_MAX);
|
||||
lstat(nbuf, &sbuf);
|
||||
if (sbuf.st_dev == dev && sbuf.st_ino == ino)
|
||||
break;
|
||||
}
|
||||
#endif /* !HAVE_STRUCT_DIRENT_D_STAT */
|
||||
}
|
||||
closedir(dir);
|
||||
if (!de)
|
||||
break; /* Not found */
|
||||
/*
|
||||
* We get the "/" free just by copying from nbuf+2 instead
|
||||
* of nbuf+3, which is where we copied the path component.
|
||||
* This means buf[pos] is always a "/".
|
||||
*/
|
||||
len = strlen(nbuf + 2);
|
||||
pos -= len;
|
||||
while (pos <= 1) {
|
||||
char *newbuf = zhalloc(2*bufsiz);
|
||||
memcpy(newbuf + bufsiz, buf, bufsiz);
|
||||
buf = newbuf;
|
||||
pos += bufsiz;
|
||||
bufsiz *= 2;
|
||||
}
|
||||
memcpy(buf + pos, nbuf + 2, len);
|
||||
#ifdef HAVE_FCHDIR
|
||||
if (d)
|
||||
return d->dirname = ztrdup(buf + pos + 1);
|
||||
#endif
|
||||
if (chdir(".."))
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fix up the directory, if necessary.
|
||||
* We're changing back down the hierarchy, ignore the
|
||||
* "/" at buf[pos].
|
||||
*/
|
||||
if (d) {
|
||||
#ifndef HAVE_FCHDIR
|
||||
if (buf[pos])
|
||||
zchdir(buf + pos + 1);
|
||||
noholdintr();
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (buf[pos])
|
||||
zchdir(buf + pos + 1);
|
||||
noholdintr();
|
||||
|
||||
#else /* __CYGWIN__, USE_GETCWD cases */
|
||||
|
||||
if (!getcwd(buf, bufsiz)) {
|
||||
if (d) {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (d) {
|
||||
return d->dirname = ztrdup(buf);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Something bad happened.
|
||||
* This has been seen when inside a special directory,
|
||||
* such as the Netapp .snapshot directory, that doesn't
|
||||
* appear as a directory entry in the parent directory.
|
||||
* We'll just need our best guess.
|
||||
*
|
||||
* We only get here from zgetcwd(); let that fall back to pwd.
|
||||
*/
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to find the current directory.
|
||||
* If we couldn't work it out internally, fall back to getcwd().
|
||||
* If it fails, fall back to pwd; if zgetcwd() is being used
|
||||
* to set pwd, pwd should be NULL and we just return ".".
|
||||
*/
|
||||
|
||||
/**/
|
||||
char *
|
||||
zgetcwd(void)
|
||||
{
|
||||
char *ret = zgetdir(NULL);
|
||||
#ifdef HAVE_GETCWD
|
||||
if (!ret) {
|
||||
#ifdef GETCWD_CALLS_MALLOC
|
||||
char *cwd = getcwd(NULL, 0);
|
||||
if (cwd) {
|
||||
ret = dupstring(cwd);
|
||||
free(cwd);
|
||||
}
|
||||
#else
|
||||
char *cwdbuf = zalloc(PATH_MAX+1);
|
||||
ret = getcwd(cwdbuf, PATH_MAX);
|
||||
if (ret)
|
||||
ret = dupstring(ret);
|
||||
zfree(cwdbuf, PATH_MAX+1);
|
||||
#endif /* GETCWD_CALLS_MALLOC */
|
||||
}
|
||||
#endif /* HAVE_GETCWD */
|
||||
if (!ret)
|
||||
ret = unmeta(pwd);
|
||||
if (!ret)
|
||||
ret = dupstring(".");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* chdir with arbitrary long pathname. Returns 0 on success, -1 on normal *
|
||||
* failure and -2 when chdir failed and the current directory is lost.
|
||||
*
|
||||
* This is to be treated as if at system level, so dir is unmetafied but
|
||||
* terminated by a NULL.
|
||||
*/
|
||||
|
||||
/**/
|
||||
mod_export int
|
||||
zchdir(char *dir)
|
||||
{
|
||||
char *s;
|
||||
int currdir = -2;
|
||||
|
||||
for (;;) {
|
||||
if (!*dir || chdir(dir) == 0) {
|
||||
#ifdef HAVE_FCHDIR
|
||||
if (currdir >= 0)
|
||||
close(currdir);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if ((errno != ENAMETOOLONG && errno != ENOMEM) ||
|
||||
strlen(dir) < PATH_MAX)
|
||||
break;
|
||||
for (s = dir + PATH_MAX - 1; s > dir && *s != '/'; s--)
|
||||
;
|
||||
if (s == dir)
|
||||
break;
|
||||
#ifdef HAVE_FCHDIR
|
||||
if (currdir == -2)
|
||||
currdir = open(".", O_RDONLY|O_NOCTTY);
|
||||
#endif
|
||||
*s = '\0';
|
||||
if (chdir(dir) < 0) {
|
||||
*s = '/';
|
||||
break;
|
||||
}
|
||||
#ifndef HAVE_FCHDIR
|
||||
currdir = -1;
|
||||
#endif
|
||||
*s = '/';
|
||||
while (*++s == '/')
|
||||
;
|
||||
dir = s;
|
||||
}
|
||||
#ifdef HAVE_FCHDIR
|
||||
if (currdir >= 0) {
|
||||
if (fchdir(currdir) < 0) {
|
||||
close(currdir);
|
||||
return -2;
|
||||
}
|
||||
close(currdir);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return currdir == -2 ? -1 : -2;
|
||||
}
|
||||
|
||||
/*
|
||||
* How to print out a 64 bit integer. This isn't needed (1) if longs
|
||||
* are 64 bit, since ordinary %ld will work (2) if we couldn't find a
|
||||
* 64 bit type anyway.
|
||||
*/
|
||||
/**/
|
||||
#ifdef ZSH_64_BIT_TYPE
|
||||
/**/
|
||||
mod_export char *
|
||||
output64(zlong val)
|
||||
{
|
||||
static char llbuf[DIGBUFSIZE];
|
||||
convbase(llbuf, val, 0);
|
||||
return llbuf;
|
||||
}
|
||||
/**/
|
||||
#endif /* ZSH_64_BIT_TYPE */
|
||||
|
||||
/**/
|
||||
#ifndef HAVE_STRTOUL
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 THE REGENTS OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Convert a string to an unsigned long integer.
|
||||
*
|
||||
* Ignores `locale' stuff. Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
|
||||
/**/
|
||||
unsigned long
|
||||
strtoul(nptr, endptr, base)
|
||||
const char *nptr;
|
||||
char **endptr;
|
||||
int base;
|
||||
{
|
||||
const char *s;
|
||||
unsigned long acc, cutoff;
|
||||
int c;
|
||||
int neg, any, cutlim;
|
||||
|
||||
/* endptr may be NULL */
|
||||
|
||||
s = nptr;
|
||||
do {
|
||||
c = (unsigned char) *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-') {
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else {
|
||||
neg = 0;
|
||||
if (c == '+')
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X')) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
|
||||
cutoff = ULONG_MAX / (unsigned long)base;
|
||||
cutlim = (int)(ULONG_MAX % (unsigned long)base);
|
||||
for (acc = 0, any = 0;; c = (unsigned char) *s++) {
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c)) {
|
||||
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
|
||||
} else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0)
|
||||
continue;
|
||||
if (acc > cutoff || (acc == cutoff && c > cutlim)) {
|
||||
any = -1;
|
||||
acc = ULONG_MAX;
|
||||
errno = ERANGE;
|
||||
} else {
|
||||
any = 1;
|
||||
acc *= (unsigned long)base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (neg && any > 0)
|
||||
acc = -acc;
|
||||
if (endptr != NULL)
|
||||
*endptr = any ? s - 1 : nptr;
|
||||
return (acc);
|
||||
}
|
||||
|
||||
/**/
|
||||
#endif /* HAVE_STRTOUL */
|
||||
|
||||
/**/
|
||||
#ifdef ENABLE_UNICODE9
|
||||
#include "./wcwidth9.h"
|
||||
|
||||
/**/
|
||||
int
|
||||
u9_wcwidth(wchar_t ucs)
|
||||
{
|
||||
int w = wcwidth9(ucs);
|
||||
if (w < -1)
|
||||
return 1;
|
||||
return w;
|
||||
}
|
||||
|
||||
/**/
|
||||
int
|
||||
u9_iswprint(wint_t ucs)
|
||||
{
|
||||
if (ucs == 0)
|
||||
return 0;
|
||||
return wcwidth9(ucs) != -1;
|
||||
}
|
||||
|
||||
/**/
|
||||
#endif /* ENABLE_UNICODE9 */
|
||||
|
||||
/**/
|
||||
#if defined(__APPLE__) && defined(BROKEN_ISPRINT)
|
||||
|
||||
/**/
|
||||
int
|
||||
isprint_ascii(int c)
|
||||
{
|
||||
if (!strcmp(nl_langinfo(CODESET), "UTF-8"))
|
||||
return (c >= 0x20 && c <= 0x7e);
|
||||
else
|
||||
return isprint(c);
|
||||
}
|
||||
|
||||
/**/
|
||||
#endif /* __APPLE__ && BROKEN_ISPRINT */
|
6250
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/exec.c
vendored
Normal file
6250
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/exec.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3913
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/glob.c
vendored
Normal file
3913
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/glob.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1617
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/hashtable.c
vendored
Normal file
1617
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/hashtable.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
69
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/hashtable.h
vendored
Normal file
69
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/hashtable.h
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* hashtable.h - header file for hash table handling code
|
||||
*
|
||||
* This file is part of zsh, the Z shell.
|
||||
*
|
||||
* Copyright (c) 1992-1997 Paul Falstad
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and to distribute modified versions of this software for any
|
||||
* purpose, provided that the above copyright notice and the following
|
||||
* two paragraphs appear in all copies of this software.
|
||||
*
|
||||
* In no event shall Paul Falstad or the Zsh Development Group be liable
|
||||
* to any party for direct, indirect, special, incidental, or consequential
|
||||
* damages arising out of the use of this software and its documentation,
|
||||
* even if Paul Falstad and the Zsh Development Group have been advised of
|
||||
* the possibility of such damage.
|
||||
*
|
||||
* Paul Falstad and the Zsh Development Group specifically disclaim any
|
||||
* warranties, including, but not limited to, the implied warranties of
|
||||
* merchantability and fitness for a particular purpose. The software
|
||||
* provided hereunder is on an "as is" basis, and Paul Falstad and the
|
||||
* Zsh Development Group have no obligation to provide maintenance,
|
||||
* support, updates, enhancements, or modifications.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Builtin function numbers; used by handler functions that handle more *
|
||||
* than one builtin. Note that builtins such as compctl, that are not *
|
||||
* overloaded, don't get a number. */
|
||||
|
||||
#define BIN_TYPESET 0
|
||||
#define BIN_BG 1
|
||||
#define BIN_FG 2
|
||||
#define BIN_JOBS 3
|
||||
#define BIN_WAIT 4
|
||||
#define BIN_DISOWN 5
|
||||
#define BIN_BREAK 6
|
||||
#define BIN_CONTINUE 7
|
||||
#define BIN_EXIT 8
|
||||
#define BIN_RETURN 9
|
||||
#define BIN_CD 10
|
||||
#define BIN_POPD 11
|
||||
#define BIN_PUSHD 12
|
||||
#define BIN_PRINT 13
|
||||
#define BIN_EVAL 14
|
||||
#define BIN_SCHED 15
|
||||
#define BIN_FC 16
|
||||
#define BIN_R 17
|
||||
#define BIN_PUSHLINE 18
|
||||
#define BIN_LOGOUT 19
|
||||
#define BIN_TEST 20
|
||||
#define BIN_BRACKET 21
|
||||
#define BIN_READONLY 22
|
||||
#define BIN_ECHO 23
|
||||
#define BIN_DISABLE 24
|
||||
#define BIN_ENABLE 25
|
||||
#define BIN_PRINTF 26
|
||||
#define BIN_COMMAND 27
|
||||
#define BIN_UNHASH 28
|
||||
#define BIN_UNALIAS 29
|
||||
#define BIN_UNFUNCTION 30
|
||||
#define BIN_UNSET 31
|
||||
|
||||
/* These currently depend on being 0 and 1. */
|
||||
#define BIN_SETOPT 0
|
||||
#define BIN_UNSETOPT 1
|
1792
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/init.c
vendored
Normal file
1792
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/init.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
701
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/input.c
vendored
Normal file
701
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/input.c
vendored
Normal file
@ -0,0 +1,701 @@
|
||||
/*
|
||||
* input.c - read and store lines of input
|
||||
*
|
||||
* This file is part of zsh, the Z shell.
|
||||
*
|
||||
* Copyright (c) 1992-1997 Paul Falstad
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and to distribute modified versions of this software for any
|
||||
* purpose, provided that the above copyright notice and the following
|
||||
* two paragraphs appear in all copies of this software.
|
||||
*
|
||||
* In no event shall Paul Falstad or the Zsh Development Group be liable
|
||||
* to any party for direct, indirect, special, incidental, or consequential
|
||||
* damages arising out of the use of this software and its documentation,
|
||||
* even if Paul Falstad and the Zsh Development Group have been advised of
|
||||
* the possibility of such damage.
|
||||
*
|
||||
* Paul Falstad and the Zsh Development Group specifically disclaim any
|
||||
* warranties, including, but not limited to, the implied warranties of
|
||||
* merchantability and fitness for a particular purpose. The software
|
||||
* provided hereunder is on an "as is" basis, and Paul Falstad and the
|
||||
* Zsh Development Group have no obligation to provide maintenance,
|
||||
* support, updates, enhancements, or modifications.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This file deals with input buffering, supplying characters to the
|
||||
* history expansion code a character at a time. Input is stored on a
|
||||
* stack, which allows insertion of strings into the input, possibly with
|
||||
* flags marking the end of alias expansion, with minimal copying of
|
||||
* strings. The same stack is used to record the fact that the input
|
||||
* is a history or alias expansion and to store the alias while it is in use.
|
||||
*
|
||||
* Input is taken either from zle, if appropriate, or read directly from
|
||||
* the input file, or may be supplied by some other part of the shell (such
|
||||
* as `eval' or $(...) substitution). In the last case, it should be
|
||||
* supplied by pushing a new level onto the stack, via inpush(input_string,
|
||||
* flag, alias); if the current input really needs to be altered, use
|
||||
* inputsetline(input_string, flag). `Flag' can include or's of INP_FREE
|
||||
* (if the input string is to be freed when used), INP_CONT (if the input
|
||||
* is to continue onto what's already in the input queue), INP_ALIAS
|
||||
* (push supplied alias onto stack) or INP_HIST (ditto, but used to
|
||||
* mark history expansion). `alias' is ignored unless INP_ALIAS or
|
||||
* INP_HIST is supplied. INP_ALIAS is always set if INP_HIST is.
|
||||
*
|
||||
* Note that the input string is itself used as the input buffer: it is not
|
||||
* copied, nor is it every written back to, so using a constant string
|
||||
* should work. Consequently, when passing areas of memory from the heap
|
||||
* it is necessary that that heap last as long as the operation of reading
|
||||
* the string. After the string is read, the stack should be popped with
|
||||
* inpop(), which effectively flushes any unread input as well as restoring
|
||||
* the previous input state.
|
||||
*
|
||||
* The internal flags INP_ALCONT and INP_HISTCONT show that the stack
|
||||
* element was pushed by an alias or history expansion; they should not
|
||||
* be needed elsewhere.
|
||||
*
|
||||
* The global variable inalmore is set to indicate aliases should
|
||||
* continue to be expanded because the last alias expansion ended
|
||||
* in a space. It is only reset after a complete word was read
|
||||
* without expanding a new alias, in exalias().
|
||||
*
|
||||
* PWS 1996/12/10
|
||||
*/
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "zsh.mdh"
|
||||
#include "input.pro"
|
||||
|
||||
/* the shell input fd */
|
||||
|
||||
/**/
|
||||
int SHIN;
|
||||
|
||||
/* buffered shell input for non-interactive shells */
|
||||
|
||||
/**/
|
||||
FILE *bshin;
|
||||
|
||||
/* != 0 means we are reading input from a string */
|
||||
|
||||
/**/
|
||||
int strin;
|
||||
|
||||
/* total # of characters waiting to be read. */
|
||||
|
||||
/**/
|
||||
mod_export int inbufct;
|
||||
|
||||
/* the flags controlling the input routines in input.c: see INP_* in zsh.h */
|
||||
|
||||
/**/
|
||||
int inbufflags;
|
||||
|
||||
static char *inbuf; /* Current input buffer */
|
||||
static char *inbufptr; /* Pointer into input buffer */
|
||||
static char *inbufpush; /* Character at which to re-push alias */
|
||||
static int inbufleft; /* Characters left in current input
|
||||
stack element */
|
||||
|
||||
|
||||
/* Input must be stacked since the input queue is used by
|
||||
* various different parts of the shell.
|
||||
*/
|
||||
|
||||
struct instacks {
|
||||
char *buf, *bufptr;
|
||||
Alias alias;
|
||||
int bufleft, bufct, flags;
|
||||
};
|
||||
static struct instacks *instack, *instacktop;
|
||||
/*
|
||||
* Input stack size. We need to push the stack for aliases, history
|
||||
* expansion, and reading from internal strings: only if these operations
|
||||
* are nested do we need more than one extra level. Thus we shouldn't need
|
||||
* too much space as a rule. Initially, INSTACK_INITIAL is allocated; if
|
||||
* more is required, an extra INSTACK_EXPAND is added each time.
|
||||
*/
|
||||
#define INSTACK_INITIAL 4
|
||||
#define INSTACK_EXPAND 4
|
||||
|
||||
static int instacksz = INSTACK_INITIAL;
|
||||
|
||||
/* Read a line from bshin. Convert tokens and *
|
||||
* null characters to Meta c^32 character pairs. */
|
||||
|
||||
/**/
|
||||
mod_export char *
|
||||
shingetline(void)
|
||||
{
|
||||
char *line = NULL;
|
||||
int ll = 0;
|
||||
int c;
|
||||
char buf[BUFSIZ];
|
||||
char *p;
|
||||
int q = queue_signal_level();
|
||||
|
||||
p = buf;
|
||||
winch_unblock();
|
||||
dont_queue_signals();
|
||||
for (;;) {
|
||||
/* Can't fgets() here because we need to accept '\0' bytes */
|
||||
do {
|
||||
errno = 0;
|
||||
c = fgetc(bshin);
|
||||
} while (c < 0 && errno == EINTR);
|
||||
if (c < 0 || c == '\n') {
|
||||
winch_block();
|
||||
restore_queue_signals(q);
|
||||
if (c == '\n')
|
||||
*p++ = '\n';
|
||||
if (p > buf) {
|
||||
*p++ = '\0';
|
||||
line = zrealloc(line, ll + (p - buf));
|
||||
memcpy(line + ll, buf, p - buf);
|
||||
}
|
||||
return line;
|
||||
}
|
||||
if (imeta(c)) {
|
||||
*p++ = Meta;
|
||||
*p++ = c ^ 32;
|
||||
} else
|
||||
*p++ = c;
|
||||
if (p >= buf + BUFSIZ - 1) {
|
||||
winch_block();
|
||||
queue_signals();
|
||||
line = zrealloc(line, ll + (p - buf) + 1);
|
||||
memcpy(line + ll, buf, p - buf);
|
||||
ll += p - buf;
|
||||
line[ll] = '\0';
|
||||
p = buf;
|
||||
winch_unblock();
|
||||
dont_queue_signals();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the next character from the input.
|
||||
* Will call inputline() to get a new line where necessary.
|
||||
*/
|
||||
|
||||
/**/
|
||||
int
|
||||
ingetc(void)
|
||||
{
|
||||
int lastc = ' ';
|
||||
|
||||
if (lexstop)
|
||||
return ' ';
|
||||
for (;;) {
|
||||
if (inbufleft) {
|
||||
inbufleft--;
|
||||
inbufct--;
|
||||
if (itok(lastc = STOUC(*inbufptr++)))
|
||||
continue;
|
||||
if (((inbufflags & INP_LINENO) || !strin) && lastc == '\n')
|
||||
lineno++;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* See if we have reached the end of input
|
||||
* (due to an error, or to reading from a single string).
|
||||
* Check the remaining characters left, since if there aren't
|
||||
* any we don't want to pop the stack---it'll mark any aliases
|
||||
* as not in use before we've finished processing.
|
||||
*/
|
||||
if (!inbufct && (strin || errflag)) {
|
||||
lexstop = 1;
|
||||
break;
|
||||
}
|
||||
/* If the next element down the input stack is a continuation of
|
||||
* this, use it.
|
||||
*/
|
||||
if (inbufflags & INP_CONT) {
|
||||
inpoptop();
|
||||
continue;
|
||||
}
|
||||
/* As a last resort, get some more input */
|
||||
if (inputline())
|
||||
break;
|
||||
}
|
||||
if (!lexstop)
|
||||
zshlex_raw_add(lastc);
|
||||
return lastc;
|
||||
}
|
||||
|
||||
/* Read a line from the current command stream and store it as input */
|
||||
|
||||
/**/
|
||||
static int
|
||||
inputline(void)
|
||||
{
|
||||
char *ingetcline, **ingetcpmptl = NULL, **ingetcpmptr = NULL;
|
||||
int context = ZLCON_LINE_START;
|
||||
|
||||
/* If reading code interactively, work out the prompts. */
|
||||
if (interact && isset(SHINSTDIN)) {
|
||||
if (!isfirstln) {
|
||||
ingetcpmptl = &prompt2;
|
||||
if (rprompt2)
|
||||
ingetcpmptr = &rprompt2;
|
||||
context = ZLCON_LINE_CONT;
|
||||
}
|
||||
else {
|
||||
ingetcpmptl = &prompt;
|
||||
if (rprompt)
|
||||
ingetcpmptr = &rprompt;
|
||||
}
|
||||
}
|
||||
if (!(interact && isset(SHINSTDIN) && SHTTY != -1 && isset(USEZLE))) {
|
||||
/*
|
||||
* If not using zle, read the line straight from the input file.
|
||||
* Possibly we don't get the whole line at once: in that case,
|
||||
* we get another chunk with the next call to inputline().
|
||||
*/
|
||||
|
||||
if (interact && isset(SHINSTDIN)) {
|
||||
/*
|
||||
* We may still be interactive (e.g. running under emacs),
|
||||
* so output a prompt if necessary. We don't know enough
|
||||
* about the input device to be able to handle an rprompt,
|
||||
* though.
|
||||
*/
|
||||
char *pptbuf;
|
||||
int pptlen;
|
||||
pptbuf = unmetafy(promptexpand(ingetcpmptl ? *ingetcpmptl : NULL,
|
||||
0, NULL, NULL, NULL), &pptlen);
|
||||
write_loop(2, pptbuf, pptlen);
|
||||
free(pptbuf);
|
||||
}
|
||||
ingetcline = shingetline();
|
||||
} else {
|
||||
/*
|
||||
* Since we may have to read multiple lines before getting
|
||||
* a complete piece of input, we tell zle not to restore the
|
||||
* original tty settings after reading each chunk. Instead,
|
||||
* this is done when the history mechanism for the current input
|
||||
* terminates, which is not until we have the whole input.
|
||||
* This is supposed to minimise problems on systems that clobber
|
||||
* typeahead when the terminal settings are altered.
|
||||
* pws 1998/03/12
|
||||
*/
|
||||
int flags = ZLRF_HISTORY|ZLRF_NOSETTY;
|
||||
if (isset(IGNOREEOF))
|
||||
flags |= ZLRF_IGNOREEOF;
|
||||
ingetcline = zleentry(ZLE_CMD_READ, ingetcpmptl, ingetcpmptr,
|
||||
flags, context);
|
||||
histdone |= HISTFLAG_SETTY;
|
||||
}
|
||||
if (!ingetcline) {
|
||||
return lexstop = 1;
|
||||
}
|
||||
if (errflag) {
|
||||
free(ingetcline);
|
||||
errflag |= ERRFLAG_ERROR;
|
||||
return lexstop = 1;
|
||||
}
|
||||
if (isset(VERBOSE)) {
|
||||
/* Output the whole line read so far. */
|
||||
zputs(ingetcline, stderr);
|
||||
fflush(stderr);
|
||||
}
|
||||
if (keyboardhackchar && *ingetcline &&
|
||||
ingetcline[strlen(ingetcline) - 1] == '\n' &&
|
||||
interact && isset(SHINSTDIN) &&
|
||||
SHTTY != -1 && ingetcline[1])
|
||||
{
|
||||
char *stripptr = ingetcline + strlen(ingetcline) - 2;
|
||||
if (*stripptr == keyboardhackchar) {
|
||||
/* Junk an unwanted character at the end of the line.
|
||||
(key too close to return key) */
|
||||
int ct = 1; /* force odd */
|
||||
char *ptr;
|
||||
|
||||
if (keyboardhackchar == '\'' || keyboardhackchar == '"' ||
|
||||
keyboardhackchar == '`') {
|
||||
/*
|
||||
* for the chars above, also require an odd count before
|
||||
* junking
|
||||
*/
|
||||
for (ct = 0, ptr = ingetcline; *ptr; ptr++)
|
||||
if (*ptr == keyboardhackchar)
|
||||
ct++;
|
||||
}
|
||||
if (ct & 1) {
|
||||
stripptr[0] = '\n';
|
||||
stripptr[1] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
isfirstch = 1;
|
||||
if ((inbufflags & INP_APPEND) && inbuf) {
|
||||
/*
|
||||
* We need new input but need to be able to back up
|
||||
* over the old input, so append this line.
|
||||
* Pushing the line onto the stack doesn't have the right
|
||||
* effect.
|
||||
*
|
||||
* This is quite a simple and inefficient fix, but currently
|
||||
* we only need it when backing up over a multi-line $((...
|
||||
* that turned out to be a command substitution rather than
|
||||
* a math substitution, which is a very special case.
|
||||
* So it's not worth rewriting.
|
||||
*/
|
||||
char *oinbuf = inbuf;
|
||||
int newlen = strlen(ingetcline);
|
||||
int oldlen = (int)(inbufptr - inbuf) + inbufleft;
|
||||
if (inbufflags & INP_FREE) {
|
||||
inbuf = realloc(inbuf, oldlen + newlen + 1);
|
||||
} else {
|
||||
inbuf = zalloc(oldlen + newlen + 1);
|
||||
memcpy(inbuf, oinbuf, oldlen);
|
||||
}
|
||||
inbufptr += inbuf - oinbuf;
|
||||
strcpy(inbuf + oldlen, ingetcline);
|
||||
free(ingetcline);
|
||||
inbufleft += newlen;
|
||||
inbufct += newlen;
|
||||
inbufflags |= INP_FREE;
|
||||
} else {
|
||||
/* Put this into the input channel. */
|
||||
inputsetline(ingetcline, INP_FREE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Put a string in the input queue:
|
||||
* inbuf is only freeable if the flags include INP_FREE.
|
||||
*/
|
||||
|
||||
/**/
|
||||
static void
|
||||
inputsetline(char *str, int flags)
|
||||
{
|
||||
queue_signals();
|
||||
|
||||
if ((inbufflags & INP_FREE) && inbuf) {
|
||||
free(inbuf);
|
||||
}
|
||||
inbuf = inbufptr = str;
|
||||
inbufleft = strlen(inbuf);
|
||||
|
||||
/*
|
||||
* inbufct must reflect the total number of characters left,
|
||||
* as it used by other parts of the shell, so we need to take account
|
||||
* of whether the input stack continues, and whether there
|
||||
* is an extra space to add on at the end.
|
||||
*/
|
||||
if (flags & INP_CONT)
|
||||
inbufct += inbufleft;
|
||||
else
|
||||
inbufct = inbufleft;
|
||||
inbufflags = flags;
|
||||
|
||||
unqueue_signals();
|
||||
}
|
||||
|
||||
/*
|
||||
* Backup one character of the input.
|
||||
* The last character can always be backed up, provided we didn't just
|
||||
* expand an alias or a history reference.
|
||||
* In fact, the character is ignored and the previous character is used.
|
||||
* (If that's wrong, the bug is in the calling code. Use the #ifdef DEBUG
|
||||
* code to check.)
|
||||
*/
|
||||
|
||||
/**/
|
||||
void
|
||||
inungetc(int c)
|
||||
{
|
||||
if (!lexstop) {
|
||||
if (inbufptr != inbuf) {
|
||||
#ifdef DEBUG
|
||||
/* Just for debugging: enable only if foul play suspected. */
|
||||
if (inbufptr[-1] != (char) c)
|
||||
fprintf(stderr, "Warning: backing up wrong character.\n");
|
||||
#endif
|
||||
/* Just decrement the pointer: if it's not the same
|
||||
* character being pushed back, we're in trouble anyway.
|
||||
*/
|
||||
inbufptr--;
|
||||
inbufct++;
|
||||
inbufleft++;
|
||||
if (((inbufflags & INP_LINENO) || !strin) && c == '\n')
|
||||
lineno--;
|
||||
}
|
||||
else if (!(inbufflags & INP_CONT)) {
|
||||
#ifdef DEBUG
|
||||
/* Just for debugging */
|
||||
fprintf(stderr, "Attempt to inungetc() at start of input.\n");
|
||||
#endif
|
||||
zerr("Garbled input at %c (binary file as commands?)", c);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* The character is being backed up from a previous input stack
|
||||
* layer. However, there was an expansion in the middle, so we
|
||||
* can't back up where we want to. Instead, we just push it
|
||||
* onto the input stack as an extra character.
|
||||
*/
|
||||
char *cback = (char *)zshcalloc(2);
|
||||
cback[0] = (char) c;
|
||||
inpush(cback, INP_FREE|INP_CONT, NULL);
|
||||
}
|
||||
/* If we are back at the start of a segment,
|
||||
* we may need to restore an alias popped from the stack.
|
||||
* Note this may be a dummy (history expansion) entry.
|
||||
*/
|
||||
if (inbufptr == inbufpush &&
|
||||
(inbufflags & (INP_ALCONT|INP_HISTCONT))) {
|
||||
/*
|
||||
* Go back up the stack over all entries which were alias
|
||||
* expansions and were pushed with nothing remaining to read.
|
||||
*/
|
||||
do {
|
||||
if (instacktop->alias)
|
||||
instacktop->alias->inuse = 1;
|
||||
instacktop++;
|
||||
} while ((instacktop->flags & (INP_ALCONT|INP_HISTCONT))
|
||||
&& !instacktop->bufleft);
|
||||
if (inbufflags & INP_HISTCONT)
|
||||
inbufflags = INP_CONT|INP_ALIAS|INP_HIST;
|
||||
else
|
||||
inbufflags = INP_CONT|INP_ALIAS;
|
||||
inbufleft = 0;
|
||||
inbuf = inbufptr = "";
|
||||
}
|
||||
zshlex_raw_back();
|
||||
}
|
||||
}
|
||||
|
||||
/* stuff a whole file into the input queue and print it */
|
||||
|
||||
/**/
|
||||
int
|
||||
stuff(char *fn)
|
||||
{
|
||||
FILE *in;
|
||||
char *buf;
|
||||
off_t len;
|
||||
|
||||
if (!(in = fopen(unmeta(fn), "r"))) {
|
||||
zerr("can't open %s", fn);
|
||||
return 1;
|
||||
}
|
||||
fseek(in, 0, 2);
|
||||
len = ftell(in);
|
||||
fseek(in, 0, 0);
|
||||
buf = (char *)zalloc(len + 1);
|
||||
if (!(fread(buf, len, 1, in))) {
|
||||
zerr("read error on %s", fn);
|
||||
fclose(in);
|
||||
zfree(buf, len + 1);
|
||||
return 1;
|
||||
}
|
||||
fclose(in);
|
||||
buf[len] = '\0';
|
||||
fwrite(buf, len, 1, stderr);
|
||||
fflush(stderr);
|
||||
inputsetline(metafy(buf, len, META_REALLOC), INP_FREE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* flush input queue */
|
||||
|
||||
/**/
|
||||
void
|
||||
inerrflush(void)
|
||||
{
|
||||
while (!lexstop && inbufct)
|
||||
ingetc();
|
||||
}
|
||||
|
||||
/* Set some new input onto a new element of the input stack */
|
||||
|
||||
/**/
|
||||
mod_export void
|
||||
inpush(char *str, int flags, Alias inalias)
|
||||
{
|
||||
if (!instack) {
|
||||
/* Initial stack allocation */
|
||||
instack = (struct instacks *)zalloc(instacksz*sizeof(struct instacks));
|
||||
instacktop = instack;
|
||||
}
|
||||
|
||||
instacktop->buf = inbuf;
|
||||
instacktop->bufptr = inbufptr;
|
||||
instacktop->bufleft = inbufleft;
|
||||
instacktop->bufct = inbufct;
|
||||
inbufflags &= ~(INP_ALCONT|INP_HISTCONT);
|
||||
if (flags & (INP_ALIAS|INP_HIST)) {
|
||||
/*
|
||||
* Text is expansion for history or alias, so continue
|
||||
* back to old level when done. Also mark stack top
|
||||
* as alias continuation so as to back up if necessary,
|
||||
* and mark alias as in use.
|
||||
*/
|
||||
flags |= INP_CONT|INP_ALIAS;
|
||||
if (flags & INP_HIST)
|
||||
instacktop->flags = inbufflags | INP_HISTCONT;
|
||||
else
|
||||
instacktop->flags = inbufflags | INP_ALCONT;
|
||||
if ((instacktop->alias = inalias))
|
||||
inalias->inuse = 1;
|
||||
} else {
|
||||
/* If we are continuing an alias expansion, record the alias
|
||||
* expansion in new set of flags (do we need this?)
|
||||
*/
|
||||
if (((instacktop->flags = inbufflags) & INP_ALIAS) &&
|
||||
(flags & INP_CONT))
|
||||
flags |= INP_ALIAS;
|
||||
}
|
||||
|
||||
instacktop++;
|
||||
if (instacktop == instack + instacksz) {
|
||||
/* Expand the stack */
|
||||
instack = (struct instacks *)
|
||||
realloc(instack,
|
||||
(instacksz + INSTACK_EXPAND)*sizeof(struct instacks));
|
||||
instacktop = instack + instacksz;
|
||||
instacksz += INSTACK_EXPAND;
|
||||
}
|
||||
/*
|
||||
* We maintain the entry above the highest one with real
|
||||
* text as a flag to inungetc() that it can stop re-pushing the stack.
|
||||
*/
|
||||
instacktop->flags = 0;
|
||||
|
||||
inbufpush = inbuf = NULL;
|
||||
|
||||
inputsetline(str, flags);
|
||||
}
|
||||
|
||||
/* Remove the top element of the stack */
|
||||
|
||||
/**/
|
||||
static void
|
||||
inpoptop(void)
|
||||
{
|
||||
if (!lexstop) {
|
||||
inbufflags &= ~(INP_ALCONT|INP_HISTCONT);
|
||||
while (inbufptr > inbuf) {
|
||||
inbufptr--;
|
||||
inbufct++;
|
||||
inbufleft++;
|
||||
/*
|
||||
* As elsewhere in input and history mechanisms:
|
||||
* unwinding aliases and unwinding history have different
|
||||
* implications as aliases are after the lexer while
|
||||
* history is before, but they're both pushed onto
|
||||
* the input stack.
|
||||
*/
|
||||
if ((inbufflags & (INP_ALIAS|INP_HIST|INP_RAW_KEEP)) == INP_ALIAS)
|
||||
zshlex_raw_back();
|
||||
}
|
||||
}
|
||||
|
||||
if (inbuf && (inbufflags & INP_FREE))
|
||||
free(inbuf);
|
||||
|
||||
instacktop--;
|
||||
|
||||
inbuf = instacktop->buf;
|
||||
inbufptr = inbufpush = instacktop->bufptr;
|
||||
inbufleft = instacktop->bufleft;
|
||||
inbufct = instacktop->bufct;
|
||||
inbufflags = instacktop->flags;
|
||||
|
||||
if (!(inbufflags & (INP_ALCONT|INP_HISTCONT)))
|
||||
return;
|
||||
|
||||
if (instacktop->alias) {
|
||||
char *t = instacktop->alias->text;
|
||||
/* a real alias: mark it as unused. */
|
||||
instacktop->alias->inuse = 0;
|
||||
if (*t && t[strlen(t) - 1] == ' ') {
|
||||
inalmore = 1;
|
||||
histbackword();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the top element of the stack and all its continuations. */
|
||||
|
||||
/**/
|
||||
mod_export void
|
||||
inpop(void)
|
||||
{
|
||||
int remcont;
|
||||
|
||||
do {
|
||||
remcont = inbufflags & INP_CONT;
|
||||
|
||||
inpoptop();
|
||||
} while (remcont);
|
||||
}
|
||||
|
||||
/*
|
||||
* Expunge any aliases from the input stack; they shouldn't appear
|
||||
* in the history and need to be flushed explicitly when we encounter
|
||||
* an error.
|
||||
*/
|
||||
|
||||
/**/
|
||||
void
|
||||
inpopalias(void)
|
||||
{
|
||||
while (inbufflags & INP_ALIAS)
|
||||
inpoptop();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get pointer to remaining string to read.
|
||||
*/
|
||||
|
||||
/**/
|
||||
char *
|
||||
ingetptr(void)
|
||||
{
|
||||
return inbufptr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if the current input line, including continuations, is
|
||||
* expanding an alias. This does not detect alias expansions that
|
||||
* have been fully processed and popped from the input stack.
|
||||
* If there is an alias, the most recently expanded is returned,
|
||||
* else NULL.
|
||||
*/
|
||||
|
||||
/**/
|
||||
char *input_hasalias(void)
|
||||
{
|
||||
int flags = inbufflags;
|
||||
struct instacks *instackptr = instacktop;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (!(flags & INP_CONT))
|
||||
break;
|
||||
instackptr--;
|
||||
if (instackptr->alias)
|
||||
return instackptr->alias->node.nam;
|
||||
flags = instackptr->flags;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
2894
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/jobs.c
vendored
Normal file
2894
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/jobs.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2203
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/lex.c
vendored
Normal file
2203
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/lex.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
795
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/loop.c
vendored
Normal file
795
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/loop.c
vendored
Normal file
@ -0,0 +1,795 @@
|
||||
/*
|
||||
* loop.c - loop execution
|
||||
*
|
||||
* This file is part of zsh, the Z shell.
|
||||
*
|
||||
* Copyright (c) 1992-1997 Paul Falstad
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and to distribute modified versions of this software for any
|
||||
* purpose, provided that the above copyright notice and the following
|
||||
* two paragraphs appear in all copies of this software.
|
||||
*
|
||||
* In no event shall Paul Falstad or the Zsh Development Group be liable
|
||||
* to any party for direct, indirect, special, incidental, or consequential
|
||||
* damages arising out of the use of this software and its documentation,
|
||||
* even if Paul Falstad and the Zsh Development Group have been advised of
|
||||
* the possibility of such damage.
|
||||
*
|
||||
* Paul Falstad and the Zsh Development Group specifically disclaim any
|
||||
* warranties, including, but not limited to, the implied warranties of
|
||||
* merchantability and fitness for a particular purpose. The software
|
||||
* provided hereunder is on an "as is" basis, and Paul Falstad and the
|
||||
* Zsh Development Group have no obligation to provide maintenance,
|
||||
* support, updates, enhancements, or modifications.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "zsh.mdh"
|
||||
#include "loop.pro"
|
||||
|
||||
/* # of nested loops we are in */
|
||||
|
||||
/**/
|
||||
int loops;
|
||||
|
||||
/* # of continue levels */
|
||||
|
||||
/**/
|
||||
mod_export int contflag;
|
||||
|
||||
/* # of break levels */
|
||||
|
||||
/**/
|
||||
mod_export int breaks;
|
||||
|
||||
/**/
|
||||
int
|
||||
execfor(Estate state, int do_exec)
|
||||
{
|
||||
Wordcode end, loop;
|
||||
wordcode code = state->pc[-1];
|
||||
int iscond = (WC_FOR_TYPE(code) == WC_FOR_COND), ctok = 0, atok = 0;
|
||||
int last = 0;
|
||||
char *name, *str, *cond = NULL, *advance = NULL;
|
||||
zlong val = 0;
|
||||
LinkList vars = NULL, args = NULL;
|
||||
int old_simple_pline = simple_pline;
|
||||
|
||||
/* See comments in execwhile() */
|
||||
simple_pline = 1;
|
||||
|
||||
end = state->pc + WC_FOR_SKIP(code);
|
||||
|
||||
if (iscond) {
|
||||
str = dupstring(ecgetstr(state, EC_NODUP, NULL));
|
||||
singsub(&str);
|
||||
if (isset(XTRACE)) {
|
||||
char *str2 = dupstring(str);
|
||||
untokenize(str2);
|
||||
printprompt4();
|
||||
fprintf(xtrerr, "%s\n", str2);
|
||||
fflush(xtrerr);
|
||||
}
|
||||
if (!errflag) {
|
||||
matheval(str);
|
||||
}
|
||||
if (errflag) {
|
||||
state->pc = end;
|
||||
simple_pline = old_simple_pline;
|
||||
return 1;
|
||||
}
|
||||
cond = ecgetstr(state, EC_NODUP, &ctok);
|
||||
advance = ecgetstr(state, EC_NODUP, &atok);
|
||||
} else {
|
||||
vars = ecgetlist(state, *state->pc++, EC_NODUP, NULL);
|
||||
|
||||
if (WC_FOR_TYPE(code) == WC_FOR_LIST) {
|
||||
int htok = 0;
|
||||
|
||||
if (!(args = ecgetlist(state, *state->pc++, EC_DUPTOK, &htok))) {
|
||||
state->pc = end;
|
||||
simple_pline = old_simple_pline;
|
||||
return 0;
|
||||
}
|
||||
if (htok) {
|
||||
execsubst(args);
|
||||
if (errflag) {
|
||||
state->pc = end;
|
||||
simple_pline = old_simple_pline;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char **x;
|
||||
|
||||
args = newlinklist();
|
||||
for (x = pparams; *x; x++)
|
||||
addlinknode(args, dupstring(*x));
|
||||
}
|
||||
}
|
||||
|
||||
if (!args || empty(args))
|
||||
lastval = 0;
|
||||
|
||||
loops++;
|
||||
pushheap();
|
||||
cmdpush(CS_FOR);
|
||||
loop = state->pc;
|
||||
while (!last) {
|
||||
if (iscond) {
|
||||
if (ctok) {
|
||||
str = dupstring(cond);
|
||||
singsub(&str);
|
||||
} else
|
||||
str = cond;
|
||||
if (!errflag) {
|
||||
while (iblank(*str))
|
||||
str++;
|
||||
if (*str) {
|
||||
if (isset(XTRACE)) {
|
||||
printprompt4();
|
||||
fprintf(xtrerr, "%s\n", str);
|
||||
fflush(xtrerr);
|
||||
}
|
||||
val = mathevali(str);
|
||||
} else
|
||||
val = 1;
|
||||
}
|
||||
if (errflag) {
|
||||
if (breaks)
|
||||
breaks--;
|
||||
lastval = 1;
|
||||
break;
|
||||
}
|
||||
if (!val)
|
||||
break;
|
||||
} else {
|
||||
LinkNode node;
|
||||
int count = 0;
|
||||
for (node = firstnode(vars); node; incnode(node))
|
||||
{
|
||||
name = (char *)getdata(node);
|
||||
if (!args || !(str = (char *) ugetnode(args)))
|
||||
{
|
||||
if (count) {
|
||||
str = "";
|
||||
last = 1;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
if (isset(XTRACE)) {
|
||||
printprompt4();
|
||||
fprintf(xtrerr, "%s=%s\n", name, str);
|
||||
fflush(xtrerr);
|
||||
}
|
||||
setsparam(name, ztrdup(str));
|
||||
count++;
|
||||
}
|
||||
if (!count)
|
||||
break;
|
||||
}
|
||||
state->pc = loop;
|
||||
execlist(state, 1, do_exec && args && empty(args));
|
||||
if (breaks) {
|
||||
breaks--;
|
||||
if (breaks || !contflag)
|
||||
break;
|
||||
contflag = 0;
|
||||
}
|
||||
if (retflag)
|
||||
break;
|
||||
if (iscond && !errflag) {
|
||||
if (atok) {
|
||||
str = dupstring(advance);
|
||||
singsub(&str);
|
||||
} else
|
||||
str = advance;
|
||||
if (isset(XTRACE)) {
|
||||
printprompt4();
|
||||
fprintf(xtrerr, "%s\n", str);
|
||||
fflush(xtrerr);
|
||||
}
|
||||
if (!errflag)
|
||||
matheval(str);
|
||||
}
|
||||
if (errflag) {
|
||||
if (breaks)
|
||||
breaks--;
|
||||
lastval = 1;
|
||||
break;
|
||||
}
|
||||
freeheap();
|
||||
}
|
||||
popheap();
|
||||
cmdpop();
|
||||
loops--;
|
||||
simple_pline = old_simple_pline;
|
||||
state->pc = end;
|
||||
this_noerrexit = 1;
|
||||
return lastval;
|
||||
}
|
||||
|
||||
/**/
|
||||
int
|
||||
execselect(Estate state, UNUSED(int do_exec))
|
||||
{
|
||||
Wordcode end, loop;
|
||||
wordcode code = state->pc[-1];
|
||||
char *str, *s, *name;
|
||||
LinkNode n;
|
||||
int i, usezle;
|
||||
FILE *inp;
|
||||
size_t more;
|
||||
LinkList args;
|
||||
int old_simple_pline = simple_pline;
|
||||
|
||||
/* See comments in execwhile() */
|
||||
simple_pline = 1;
|
||||
|
||||
end = state->pc + WC_FOR_SKIP(code);
|
||||
name = ecgetstr(state, EC_NODUP, NULL);
|
||||
|
||||
if (WC_SELECT_TYPE(code) == WC_SELECT_PPARAM) {
|
||||
char **x;
|
||||
|
||||
args = newlinklist();
|
||||
for (x = pparams; *x; x++)
|
||||
addlinknode(args, dupstring(*x));
|
||||
} else {
|
||||
int htok = 0;
|
||||
|
||||
if (!(args = ecgetlist(state, *state->pc++, EC_DUPTOK, &htok))) {
|
||||
state->pc = end;
|
||||
simple_pline = old_simple_pline;
|
||||
return 0;
|
||||
}
|
||||
if (htok) {
|
||||
execsubst(args);
|
||||
if (errflag) {
|
||||
state->pc = end;
|
||||
simple_pline = old_simple_pline;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!args || empty(args)) {
|
||||
state->pc = end;
|
||||
simple_pline = old_simple_pline;
|
||||
return 0;
|
||||
}
|
||||
loops++;
|
||||
|
||||
pushheap();
|
||||
cmdpush(CS_SELECT);
|
||||
usezle = interact && SHTTY != -1 && isset(USEZLE);
|
||||
inp = fdopen(dup(usezle ? SHTTY : 0), "r");
|
||||
more = selectlist(args, 0);
|
||||
loop = state->pc;
|
||||
for (;;) {
|
||||
for (;;) {
|
||||
if (empty(bufstack)) {
|
||||
if (usezle) {
|
||||
int oef = errflag;
|
||||
|
||||
isfirstln = 1;
|
||||
str = zleentry(ZLE_CMD_READ, &prompt3, NULL,
|
||||
0, ZLCON_SELECT);
|
||||
if (errflag)
|
||||
str = NULL;
|
||||
/* Keep any user interrupt error status */
|
||||
errflag = oef | (errflag & ERRFLAG_INT);
|
||||
} else {
|
||||
str = promptexpand(prompt3, 0, NULL, NULL, NULL);
|
||||
zputs(str, stderr);
|
||||
free(str);
|
||||
fflush(stderr);
|
||||
str = fgets(zhalloc(256), 256, inp);
|
||||
}
|
||||
} else
|
||||
str = (char *)getlinknode(bufstack);
|
||||
if (!str && !errflag)
|
||||
setsparam("REPLY", ztrdup("")); /* EOF (user pressed Ctrl+D) */
|
||||
if (!str || errflag) {
|
||||
if (breaks)
|
||||
breaks--;
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
goto done;
|
||||
}
|
||||
if ((s = strchr(str, '\n')))
|
||||
*s = '\0';
|
||||
if (*str)
|
||||
break;
|
||||
more = selectlist(args, more);
|
||||
}
|
||||
setsparam("REPLY", ztrdup(str));
|
||||
i = atoi(str);
|
||||
if (!i)
|
||||
str = "";
|
||||
else {
|
||||
for (i--, n = firstnode(args); n && i; incnode(n), i--);
|
||||
if (n)
|
||||
str = (char *) getdata(n);
|
||||
else
|
||||
str = "";
|
||||
}
|
||||
setsparam(name, ztrdup(str));
|
||||
state->pc = loop;
|
||||
execlist(state, 1, 0);
|
||||
freeheap();
|
||||
if (breaks) {
|
||||
breaks--;
|
||||
if (breaks || !contflag)
|
||||
break;
|
||||
contflag = 0;
|
||||
}
|
||||
if (retflag || errflag)
|
||||
break;
|
||||
}
|
||||
done:
|
||||
cmdpop();
|
||||
popheap();
|
||||
fclose(inp);
|
||||
loops--;
|
||||
simple_pline = old_simple_pline;
|
||||
state->pc = end;
|
||||
this_noerrexit = 1;
|
||||
return lastval;
|
||||
}
|
||||
|
||||
/* And this is used to print select lists. */
|
||||
|
||||
/**/
|
||||
size_t
|
||||
selectlist(LinkList l, size_t start)
|
||||
{
|
||||
size_t longest = 1, fct, fw = 0, colsz, t0, t1, ct;
|
||||
char **arr, **ap;
|
||||
|
||||
zleentry(ZLE_CMD_TRASH);
|
||||
arr = hlinklist2array(l, 0);
|
||||
for (ap = arr; *ap; ap++)
|
||||
if (strlen(*ap) > longest)
|
||||
longest = strlen(*ap);
|
||||
t0 = ct = ap - arr;
|
||||
longest++;
|
||||
while (t0)
|
||||
t0 /= 10, longest++;
|
||||
/* to compensate for added ')' */
|
||||
fct = (zterm_columns - 1) / (longest + 3);
|
||||
if (fct == 0)
|
||||
fct = 1;
|
||||
else
|
||||
fw = (zterm_columns - 1) / fct;
|
||||
colsz = (ct + fct - 1) / fct;
|
||||
for (t1 = start; t1 != colsz && t1 - start < zterm_lines - 2; t1++) {
|
||||
ap = arr + t1;
|
||||
do {
|
||||
size_t t2 = strlen(*ap) + 2;
|
||||
int t3;
|
||||
|
||||
fprintf(stderr, "%d) %s", t3 = ap - arr + 1, *ap);
|
||||
while (t3)
|
||||
t2++, t3 /= 10;
|
||||
for (; t2 < fw; t2++)
|
||||
fputc(' ', stderr);
|
||||
for (t0 = colsz; t0 && *ap; t0--, ap++);
|
||||
}
|
||||
while (*ap);
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
/* Below is a simple attempt at doing it the Korn Way..
|
||||
ap = arr;
|
||||
t0 = 0;
|
||||
do {
|
||||
t0++;
|
||||
fprintf(stderr,"%d) %s\n",t0,*ap);
|
||||
ap++;
|
||||
}
|
||||
while (*ap);*/
|
||||
fflush(stderr);
|
||||
|
||||
return t1 < colsz ? t1 : 0;
|
||||
}
|
||||
|
||||
/**/
|
||||
int
|
||||
execwhile(Estate state, UNUSED(int do_exec))
|
||||
{
|
||||
Wordcode end, loop;
|
||||
wordcode code = state->pc[-1];
|
||||
int olderrexit, oldval, isuntil = (WC_WHILE_TYPE(code) == WC_WHILE_UNTIL);
|
||||
int old_simple_pline = simple_pline;
|
||||
|
||||
end = state->pc + WC_WHILE_SKIP(code);
|
||||
olderrexit = noerrexit;
|
||||
oldval = 0;
|
||||
pushheap();
|
||||
cmdpush(isuntil ? CS_UNTIL : CS_WHILE);
|
||||
loops++;
|
||||
loop = state->pc;
|
||||
|
||||
if (loop[0] == WC_END && loop[1] == WC_END) {
|
||||
|
||||
/* This is an empty loop. Make sure the signal handler sets the
|
||||
* flags and then just wait for someone hitting ^C. */
|
||||
|
||||
simple_pline = 1;
|
||||
|
||||
while (!breaks)
|
||||
;
|
||||
breaks--;
|
||||
|
||||
simple_pline = old_simple_pline;
|
||||
} else
|
||||
for (;;) {
|
||||
state->pc = loop;
|
||||
noerrexit = NOERREXIT_EXIT | NOERREXIT_RETURN;
|
||||
|
||||
/* In case the test condition is a functional no-op,
|
||||
* make sure signal handlers recognize ^C to end the loop. */
|
||||
simple_pline = 1;
|
||||
|
||||
execlist(state, 1, 0);
|
||||
|
||||
simple_pline = old_simple_pline;
|
||||
noerrexit = olderrexit;
|
||||
if (!((lastval == 0) ^ isuntil)) {
|
||||
if (breaks)
|
||||
breaks--;
|
||||
if (!retflag)
|
||||
lastval = oldval;
|
||||
break;
|
||||
}
|
||||
if (retflag)
|
||||
break;
|
||||
|
||||
/* In case the loop body is also a functional no-op,
|
||||
* make sure signal handlers recognize ^C as above. */
|
||||
simple_pline = 1;
|
||||
|
||||
execlist(state, 1, 0);
|
||||
|
||||
simple_pline = old_simple_pline;
|
||||
if (breaks) {
|
||||
breaks--;
|
||||
if (breaks || !contflag)
|
||||
break;
|
||||
contflag = 0;
|
||||
}
|
||||
if (errflag) {
|
||||
lastval = 1;
|
||||
break;
|
||||
}
|
||||
if (retflag)
|
||||
break;
|
||||
freeheap();
|
||||
oldval = lastval;
|
||||
}
|
||||
cmdpop();
|
||||
popheap();
|
||||
loops--;
|
||||
state->pc = end;
|
||||
this_noerrexit = 1;
|
||||
return lastval;
|
||||
}
|
||||
|
||||
/**/
|
||||
int
|
||||
execrepeat(Estate state, UNUSED(int do_exec))
|
||||
{
|
||||
Wordcode end, loop;
|
||||
wordcode code = state->pc[-1];
|
||||
int count, htok = 0;
|
||||
char *tmp;
|
||||
int old_simple_pline = simple_pline;
|
||||
|
||||
/* See comments in execwhile() */
|
||||
simple_pline = 1;
|
||||
|
||||
end = state->pc + WC_REPEAT_SKIP(code);
|
||||
|
||||
lastval = 0;
|
||||
tmp = ecgetstr(state, EC_DUPTOK, &htok);
|
||||
if (htok)
|
||||
singsub(&tmp);
|
||||
count = mathevali(tmp);
|
||||
if (errflag)
|
||||
return 1;
|
||||
pushheap();
|
||||
cmdpush(CS_REPEAT);
|
||||
loops++;
|
||||
loop = state->pc;
|
||||
while (count-- > 0) {
|
||||
state->pc = loop;
|
||||
execlist(state, 1, 0);
|
||||
freeheap();
|
||||
if (breaks) {
|
||||
breaks--;
|
||||
if (breaks || !contflag)
|
||||
break;
|
||||
contflag = 0;
|
||||
}
|
||||
if (errflag) {
|
||||
lastval = 1;
|
||||
break;
|
||||
}
|
||||
if (retflag)
|
||||
break;
|
||||
}
|
||||
cmdpop();
|
||||
popheap();
|
||||
loops--;
|
||||
simple_pline = old_simple_pline;
|
||||
state->pc = end;
|
||||
this_noerrexit = 1;
|
||||
return lastval;
|
||||
}
|
||||
|
||||
/**/
|
||||
int
|
||||
execif(Estate state, int do_exec)
|
||||
{
|
||||
Wordcode end, next;
|
||||
wordcode code = state->pc[-1];
|
||||
int olderrexit, s = 0, run = 0;
|
||||
|
||||
olderrexit = noerrexit;
|
||||
end = state->pc + WC_IF_SKIP(code);
|
||||
|
||||
noerrexit |= NOERREXIT_EXIT | NOERREXIT_RETURN;
|
||||
while (state->pc < end) {
|
||||
code = *state->pc++;
|
||||
if (wc_code(code) != WC_IF ||
|
||||
(run = (WC_IF_TYPE(code) == WC_IF_ELSE))) {
|
||||
if (run)
|
||||
run = 2;
|
||||
break;
|
||||
}
|
||||
next = state->pc + WC_IF_SKIP(code);
|
||||
cmdpush(s ? CS_ELIF : CS_IF);
|
||||
execlist(state, 1, 0);
|
||||
cmdpop();
|
||||
if (!lastval) {
|
||||
run = 1;
|
||||
break;
|
||||
}
|
||||
if (retflag)
|
||||
break;
|
||||
s = 1;
|
||||
state->pc = next;
|
||||
}
|
||||
|
||||
if (run) {
|
||||
/* we need to ignore lastval until we reach execcmd() */
|
||||
if (olderrexit)
|
||||
noerrexit = olderrexit;
|
||||
else if (lastval)
|
||||
noerrexit |= NOERREXIT_EXIT | NOERREXIT_RETURN | NOERREXIT_UNTIL_EXEC;
|
||||
else
|
||||
noerrexit &= ~ (NOERREXIT_EXIT | NOERREXIT_RETURN);
|
||||
cmdpush(run == 2 ? CS_ELSE : (s ? CS_ELIFTHEN : CS_IFTHEN));
|
||||
execlist(state, 1, do_exec);
|
||||
cmdpop();
|
||||
} else {
|
||||
noerrexit = olderrexit;
|
||||
if (!retflag)
|
||||
lastval = 0;
|
||||
}
|
||||
state->pc = end;
|
||||
this_noerrexit = 1;
|
||||
|
||||
return lastval;
|
||||
}
|
||||
|
||||
/**/
|
||||
int
|
||||
execcase(Estate state, int do_exec)
|
||||
{
|
||||
Wordcode end, next;
|
||||
wordcode code = state->pc[-1];
|
||||
char *word, *pat;
|
||||
int npat, save, nalts, ialt, patok, anypatok;
|
||||
Patprog *spprog, pprog;
|
||||
|
||||
end = state->pc + WC_CASE_SKIP(code);
|
||||
|
||||
word = ecgetstr(state, EC_DUP, NULL);
|
||||
singsub(&word);
|
||||
untokenize(word);
|
||||
anypatok = 0;
|
||||
|
||||
cmdpush(CS_CASE);
|
||||
while (state->pc < end) {
|
||||
code = *state->pc++;
|
||||
if (wc_code(code) != WC_CASE)
|
||||
break;
|
||||
|
||||
save = 0;
|
||||
next = state->pc + WC_CASE_SKIP(code);
|
||||
nalts = *state->pc++;
|
||||
ialt = patok = 0;
|
||||
|
||||
if (isset(XTRACE)) {
|
||||
printprompt4();
|
||||
fprintf(xtrerr, "case %s (", word);
|
||||
}
|
||||
|
||||
while (!patok && nalts) {
|
||||
npat = state->pc[1];
|
||||
spprog = state->prog->pats + npat;
|
||||
pprog = NULL;
|
||||
pat = NULL;
|
||||
|
||||
queue_signals();
|
||||
|
||||
if (isset(XTRACE)) {
|
||||
int htok = 0;
|
||||
pat = dupstring(ecrawstr(state->prog, state->pc, &htok));
|
||||
if (htok)
|
||||
singsub(&pat);
|
||||
|
||||
if (ialt++)
|
||||
fprintf(stderr, " | ");
|
||||
quote_tokenized_output(pat, xtrerr);
|
||||
}
|
||||
|
||||
if (*spprog != dummy_patprog1 && *spprog != dummy_patprog2)
|
||||
pprog = *spprog;
|
||||
|
||||
if (!pprog) {
|
||||
if (!pat) {
|
||||
char *opat;
|
||||
int htok = 0;
|
||||
|
||||
pat = dupstring(opat = ecrawstr(state->prog,
|
||||
state->pc, &htok));
|
||||
if (htok)
|
||||
singsub(&pat);
|
||||
save = (!(state->prog->flags & EF_HEAP) &&
|
||||
!strcmp(pat, opat) && *spprog != dummy_patprog2);
|
||||
}
|
||||
if (!(pprog = patcompile(pat, (save ? PAT_ZDUP : PAT_STATIC),
|
||||
NULL)))
|
||||
zerr("bad pattern: %s", pat);
|
||||
else if (save)
|
||||
*spprog = pprog;
|
||||
}
|
||||
if (pprog && pattry(pprog, word))
|
||||
patok = anypatok = 1;
|
||||
state->pc += 2;
|
||||
nalts--;
|
||||
|
||||
unqueue_signals();
|
||||
}
|
||||
state->pc += 2 * nalts;
|
||||
if (isset(XTRACE)) {
|
||||
fprintf(xtrerr, ")\n");
|
||||
fflush(xtrerr);
|
||||
}
|
||||
if (patok) {
|
||||
execlist(state, 1, ((WC_CASE_TYPE(code) == WC_CASE_OR) &&
|
||||
do_exec));
|
||||
while (!retflag && wc_code(code) == WC_CASE &&
|
||||
WC_CASE_TYPE(code) == WC_CASE_AND && state->pc < end) {
|
||||
state->pc = next;
|
||||
code = *state->pc++;
|
||||
next = state->pc + WC_CASE_SKIP(code);
|
||||
nalts = *state->pc++;
|
||||
state->pc += 2 * nalts;
|
||||
execlist(state, 1, ((WC_CASE_TYPE(code) == WC_CASE_OR) &&
|
||||
do_exec));
|
||||
}
|
||||
if (WC_CASE_TYPE(code) != WC_CASE_TESTAND)
|
||||
break;
|
||||
}
|
||||
state->pc = next;
|
||||
}
|
||||
cmdpop();
|
||||
|
||||
state->pc = end;
|
||||
|
||||
if (!anypatok)
|
||||
lastval = 0;
|
||||
this_noerrexit = 1;
|
||||
|
||||
return lastval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Errflag from `try' block, may be reset in `always' block.
|
||||
* Accessible from an integer parameter, so needs to be a zlong.
|
||||
*/
|
||||
|
||||
/**/
|
||||
zlong
|
||||
try_errflag = -1;
|
||||
|
||||
/**
|
||||
* Corresponding interrupt error status form `try' block.
|
||||
*/
|
||||
|
||||
/**/
|
||||
zlong
|
||||
try_interrupt = -1;
|
||||
|
||||
/**/
|
||||
zlong
|
||||
try_tryflag = 0;
|
||||
|
||||
/**/
|
||||
int
|
||||
exectry(Estate state, int do_exec)
|
||||
{
|
||||
Wordcode end, always;
|
||||
int endval;
|
||||
int save_retflag, save_breaks, save_contflag;
|
||||
zlong save_try_errflag, save_try_tryflag, save_try_interrupt;
|
||||
|
||||
end = state->pc + WC_TRY_SKIP(state->pc[-1]);
|
||||
always = state->pc + 1 + WC_TRY_SKIP(*state->pc);
|
||||
state->pc++;
|
||||
pushheap();
|
||||
cmdpush(CS_CURSH);
|
||||
|
||||
/* The :try clause */
|
||||
save_try_tryflag = try_tryflag;
|
||||
try_tryflag = 1;
|
||||
|
||||
execlist(state, 1, do_exec);
|
||||
|
||||
try_tryflag = save_try_tryflag;
|
||||
|
||||
/* Don't record errflag here, may be reset. However, */
|
||||
/* endval should show failure when there is an error. */
|
||||
endval = lastval ? lastval : errflag;
|
||||
|
||||
freeheap();
|
||||
|
||||
cmdpop();
|
||||
cmdpush(CS_ALWAYS);
|
||||
|
||||
/* The always clause. */
|
||||
save_try_errflag = try_errflag;
|
||||
save_try_interrupt = try_interrupt;
|
||||
try_errflag = (zlong)(errflag & ERRFLAG_ERROR);
|
||||
try_interrupt = (zlong)((errflag & ERRFLAG_INT) ? 1 : 0);
|
||||
/* We need to reset all errors to allow the block to execute */
|
||||
errflag = 0;
|
||||
save_retflag = retflag;
|
||||
retflag = 0;
|
||||
save_breaks = breaks;
|
||||
breaks = 0;
|
||||
save_contflag = contflag;
|
||||
contflag = 0;
|
||||
|
||||
state->pc = always;
|
||||
execlist(state, 1, do_exec);
|
||||
|
||||
if (try_errflag)
|
||||
errflag |= ERRFLAG_ERROR;
|
||||
else
|
||||
errflag &= ~ERRFLAG_ERROR;
|
||||
if (try_interrupt)
|
||||
errflag |= ERRFLAG_INT;
|
||||
else
|
||||
errflag &= ~ERRFLAG_INT;
|
||||
try_errflag = save_try_errflag;
|
||||
try_interrupt = save_try_interrupt;
|
||||
if (!retflag)
|
||||
retflag = save_retflag;
|
||||
if (!breaks)
|
||||
breaks = save_breaks;
|
||||
if (!contflag)
|
||||
contflag = save_contflag;
|
||||
|
||||
cmdpop();
|
||||
popheap();
|
||||
state->pc = end;
|
||||
|
||||
return endval;
|
||||
}
|
166
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/makepro.awk
vendored
Normal file
166
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/makepro.awk
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
#
|
||||
# makepro.awk - generate prototype lists
|
||||
#
|
||||
|
||||
BEGIN {
|
||||
aborting = 0
|
||||
|
||||
# arg 1 is the name of the file to process
|
||||
# arg 2 is the name of the subdirectory it is in
|
||||
if(ARGC != 3) {
|
||||
aborting = 1
|
||||
exit 1
|
||||
}
|
||||
name = ARGV[1]
|
||||
gsub(/^.*\//, "", name)
|
||||
gsub(/\.c$/, "", name)
|
||||
name = ARGV[2] "_" name
|
||||
gsub(/\//, "_", name)
|
||||
ARGC--
|
||||
|
||||
printf "E#ifndef have_%s_globals\n", name
|
||||
printf "E#define have_%s_globals\n", name
|
||||
printf "E\n"
|
||||
}
|
||||
|
||||
# all relevant declarations are preceded by "/**/" on a line by itself
|
||||
|
||||
/^\/\*\*\/$/ {
|
||||
# The declaration is on following lines. The interesting part might
|
||||
# be terminated by a `{' (`int foo(void) { }' or `int bar[] = {')
|
||||
# or `;' (`int x;').
|
||||
line = ""
|
||||
isfunc = 0
|
||||
while(1) {
|
||||
if(getline <= 0) {
|
||||
aborting = 1
|
||||
exit 1
|
||||
}
|
||||
if (line == "" && $0 ~ /^[ \t]*#/) {
|
||||
# Directly after the /**/ was a preprocessor line.
|
||||
# Spit it out and re-start the outer loop.
|
||||
printf "E%s\n", $0
|
||||
printf "L%s\n", $0
|
||||
next
|
||||
}
|
||||
gsub(/\t/, " ")
|
||||
line = line " " $0
|
||||
gsub(/\/\*([^*]|\*+[^*\/])*\*+\//, " ", line)
|
||||
if(line ~ /\/\*/)
|
||||
continue
|
||||
# If it is a function definition, note so.
|
||||
if(line ~ /\) *(VA_DCL )*[{].*$/) #}
|
||||
isfunc = 1
|
||||
if(sub(/ *[{;].*$/, "", line)) #}
|
||||
break
|
||||
}
|
||||
if (!match(line, /VA_ALIST/)) {
|
||||
# Put spaces around each identifier.
|
||||
while(match(line, /[^_0-9A-Za-z ][_0-9A-Za-z]/) ||
|
||||
match(line, /[_0-9A-Za-z][^_0-9A-Za-z ]/))
|
||||
line = substr(line, 1, RSTART) " " substr(line, RSTART+1)
|
||||
}
|
||||
# Separate declarations into a type and a list of declarators.
|
||||
# In each declarator, "@{" and "@}" are used in place of parens to
|
||||
# mark function parameter lists, and "@!" is used in place of commas
|
||||
# in parameter lists. "@<" and "@>" are used in place of
|
||||
# non-parameter list parens.
|
||||
gsub(/ _ +/, " _ ", line)
|
||||
while(1) {
|
||||
if(isfunc && match(line, /\([^()]*\)$/))
|
||||
line = substr(line, 1, RSTART-1) " _ (" substr(line, RSTART) ")"
|
||||
else if(match(line, / _ \(\([^,()]*,/))
|
||||
line = substr(line, 1, RSTART+RLENGTH-2) "@!" substr(line, RSTART+RLENGTH)
|
||||
else if(match(line, / _ \(\([^,()]*\)\)/))
|
||||
line = substr(line, 1, RSTART-1) "@{" substr(line, RSTART+5, RLENGTH-7) "@}" substr(line, RSTART+RLENGTH)
|
||||
else if(match(line, /\([^,()]*\)/))
|
||||
line = substr(line, 1, RSTART-1) "@<" substr(line, RSTART+1, RLENGTH-2) "@>" substr(line, RSTART+RLENGTH)
|
||||
else
|
||||
break
|
||||
}
|
||||
sub(/^ */, "", line)
|
||||
match(line, /^((const|enum|mod_export|static|struct|union) +)*([_0-9A-Za-z]+ +|((char|double|float|int|long|short|unsigned|void) +)+)((const|static) +)*/)
|
||||
dtype = substr(line, 1, RLENGTH)
|
||||
sub(/ *$/, "", dtype)
|
||||
if(" " dtype " " ~ / static /)
|
||||
locality = "L"
|
||||
else
|
||||
locality = "E"
|
||||
exported = " " dtype " " ~ / mod_export /
|
||||
line = substr(line, RLENGTH+1) ","
|
||||
# Handle each declarator.
|
||||
if (match(line, /VA_ALIST/)) {
|
||||
# Already has VARARGS handling.
|
||||
|
||||
# Put parens etc. back
|
||||
gsub(/@[{]/, "((", line)
|
||||
gsub(/@}/, "))", line)
|
||||
gsub(/@</, "(", line)
|
||||
gsub(/@>/, ")", line)
|
||||
gsub(/@!/, ",", line)
|
||||
sub(/,$/, ";", line)
|
||||
gsub(/mod_export/, "mod_import_function", dtype)
|
||||
gsub(/VA_ALIST/, "VA_ALIST_PROTO", line)
|
||||
sub(/ VA_DCL/, "", line)
|
||||
|
||||
if(locality ~ /E/)
|
||||
dtype = "extern " dtype
|
||||
|
||||
if (match(line, /[_0-9A-Za-z]+\(VA_ALIST/))
|
||||
dnam = substr(line, RSTART, RLENGTH-9)
|
||||
|
||||
# If this is exported, add it to the exported symbol list.
|
||||
if (exported)
|
||||
printf "X%s\n", dnam
|
||||
|
||||
printf "%s%s %s\n", locality, dtype, line
|
||||
} else {
|
||||
while(match(line, /^[^,]*,/)) {
|
||||
# Separate out the name from the declarator. Use "@+" and "@-"
|
||||
# to bracket the name within the declarator. Strip off any
|
||||
# initialiser.
|
||||
dcltor = substr(line, 1, RLENGTH-1)
|
||||
line = substr(line, RLENGTH+1)
|
||||
sub(/\=.*$/, "", dcltor)
|
||||
match(dcltor, /^([^_0-9A-Za-z]| const )*/)
|
||||
dcltor = substr(dcltor, 1, RLENGTH) "@+" substr(dcltor, RLENGTH+1)
|
||||
match(dcltor, /^.*@\+[_0-9A-Za-z]+/)
|
||||
dcltor = substr(dcltor, 1, RLENGTH) "@-" substr(dcltor, RLENGTH+1)
|
||||
dnam = dcltor
|
||||
sub(/^.*@\+/, "", dnam)
|
||||
sub(/@-.*$/, "", dnam)
|
||||
|
||||
# Put parens etc. back
|
||||
gsub(/@[{]/, " _((", dcltor)
|
||||
gsub(/@}/, "))", dcltor)
|
||||
gsub(/@</, "(", dcltor)
|
||||
gsub(/@>/, ")", dcltor)
|
||||
gsub(/@!/, ",", dcltor)
|
||||
|
||||
# If this is exported, add it to the exported symbol list.
|
||||
if(exported)
|
||||
printf "X%s\n", dnam
|
||||
|
||||
# Format the declaration for output
|
||||
dcl = dtype " " dcltor ";"
|
||||
if(locality ~ /E/)
|
||||
dcl = "extern " dcl
|
||||
if(isfunc)
|
||||
gsub(/ mod_export /, " mod_import_function ", dcl)
|
||||
else
|
||||
gsub(/ mod_export /, " mod_import_variable ", dcl)
|
||||
gsub(/@[+-]/, "", dcl)
|
||||
gsub(/ +/, " ", dcl)
|
||||
while(match(dcl, /[^_0-9A-Za-z] ./) || match(dcl, /. [^_0-9A-Za-z]/))
|
||||
dcl = substr(dcl, 1, RSTART) substr(dcl, RSTART+2)
|
||||
printf "%s%s\n", locality, dcl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
END {
|
||||
if(aborting)
|
||||
exit 1
|
||||
printf "E\n"
|
||||
printf "E#endif /* !have_%s_globals */\n", name
|
||||
}
|
1899
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/mem.c
vendored
Normal file
1899
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/mem.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
116
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/mkbltnmlst.sh
vendored
Normal file
116
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/mkbltnmlst.sh
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# mkbltnmlst.sh: generate boot code for linked-in modules
|
||||
#
|
||||
# Written by Andrew Main
|
||||
#
|
||||
|
||||
srcdir=${srcdir-`echo $0|sed 's%/[^/][^/]*$%%'`}
|
||||
test "x$srcdir" = "x$0" && srcdir=.
|
||||
test "x$srcdir" = "x" && srcdir=.
|
||||
CFMOD=${CFMOD-$srcdir/../config.modules}
|
||||
|
||||
bin_mods="`grep ' link=static' $CFMOD | sed -e '/^#/d' \
|
||||
-e 's/ .*/ /' -e 's/^name=/ /'`"
|
||||
|
||||
x_mods="`grep ' load=yes' $CFMOD | sed -e '/^#/d' -e '/ link=no/d' \
|
||||
-e 's/ .*/ /' -e 's/^name=/ /'`"
|
||||
|
||||
trap "rm -f $1; exit 1" 1 2 15
|
||||
|
||||
exec > $1
|
||||
|
||||
for x_mod in $x_mods; do
|
||||
modfile="`grep '^name='$x_mod' ' $CFMOD | sed -e 's/^.* modfile=//' \
|
||||
-e 's/ .*//'`"
|
||||
if test "x$modfile" = x; then
|
||||
echo >&2 "WARNING: no name for \`$x_mod' in $CFMOD (ignored)"
|
||||
continue
|
||||
fi
|
||||
case "$bin_mods" in
|
||||
*" $x_mod "*)
|
||||
echo "/* linked-in known module \`$x_mod' */"
|
||||
linked=yes
|
||||
;;
|
||||
*)
|
||||
echo "#ifdef DYNAMIC"
|
||||
echo "/* non-linked-in known module \`$x_mod' */"
|
||||
linked=no
|
||||
esac
|
||||
unset moddeps autofeatures autofeatures_emu
|
||||
. $srcdir/../$modfile
|
||||
if test "x$autofeatures" != x; then
|
||||
if test "x$autofeatures_emu" != x; then
|
||||
echo " {"
|
||||
echo " char *zsh_features[] = { "
|
||||
for feature in $autofeatures; do
|
||||
echo " \"$feature\","
|
||||
done
|
||||
echo " NULL"
|
||||
echo " }; "
|
||||
echo " char *emu_features[] = { "
|
||||
for feature in $autofeatures_emu; do
|
||||
echo " \"$feature\","
|
||||
done
|
||||
echo " NULL"
|
||||
echo " }; "
|
||||
echo " autofeatures(\"zsh\", \"$x_mod\","
|
||||
echo " EMULATION(EMULATE_ZSH) ? zsh_features : emu_features,"
|
||||
echo " 0, 1);"
|
||||
echo " }"
|
||||
else
|
||||
echo " if (EMULATION(EMULATE_ZSH)) {"
|
||||
echo " char *features[] = { "
|
||||
for feature in $autofeatures; do
|
||||
echo " \"$feature\","
|
||||
done
|
||||
echo " NULL"
|
||||
echo " }; "
|
||||
echo " autofeatures(\"zsh\", \"$x_mod\", features, 0, 1);"
|
||||
echo " }"
|
||||
fi
|
||||
fi
|
||||
for dep in $moddeps; do
|
||||
echo " add_dep(\"$x_mod\", \"$dep\");"
|
||||
done
|
||||
test "x$linked" = xno && echo "#endif"
|
||||
done
|
||||
|
||||
echo
|
||||
done_mods=" "
|
||||
for bin_mod in $bin_mods; do
|
||||
q_bin_mod=`echo $bin_mod | sed 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'`
|
||||
modfile="`grep '^name='$bin_mod' ' $CFMOD | sed -e 's/^.* modfile=//' \
|
||||
-e 's/ .*//'`"
|
||||
echo "/* linked-in module \`$bin_mod' */"
|
||||
unset moddeps
|
||||
. $srcdir/../$modfile
|
||||
for dep in $moddeps; do
|
||||
# This assumes there are no circular dependencies in the builtin
|
||||
# modules. Better ordering of config.modules would be necessary
|
||||
# to enforce stricter dependency checking.
|
||||
case $bin_mods in
|
||||
*" $dep "*)
|
||||
echo " /* depends on \`$dep' */" ;;
|
||||
*) echo >&2 "ERROR: linked-in module \`$bin_mod' depends on \`$dep'"
|
||||
rm -f $1
|
||||
exit 1 ;;
|
||||
esac
|
||||
done
|
||||
echo " {"
|
||||
echo " extern int setup_${q_bin_mod} _((Module));"
|
||||
echo " extern int boot_${q_bin_mod} _((Module));"
|
||||
echo " extern int features_${q_bin_mod} _((Module,char***));"
|
||||
echo " extern int enables_${q_bin_mod} _((Module,int**));"
|
||||
echo " extern int cleanup_${q_bin_mod} _((Module));"
|
||||
echo " extern int finish_${q_bin_mod} _((Module));"
|
||||
echo
|
||||
echo " register_module(\"$bin_mod\","
|
||||
echo " setup_${q_bin_mod},"
|
||||
echo " features_${q_bin_mod},"
|
||||
echo " enables_${q_bin_mod},"
|
||||
echo " boot_${q_bin_mod},"
|
||||
echo " cleanup_${q_bin_mod}, finish_${q_bin_mod});"
|
||||
echo " }"
|
||||
done_mods="$done_mods$bin_mod "
|
||||
done
|
468
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/mkmakemod.sh
vendored
Normal file
468
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/mkmakemod.sh
vendored
Normal file
@ -0,0 +1,468 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# mkmakemod.sh: generate Makefile.in files for module building
|
||||
#
|
||||
# Options:
|
||||
# -m = file is already generated; only build the second stage
|
||||
# -i = do not build second stage
|
||||
#
|
||||
# Args:
|
||||
# $1 = subdirectory to look in, relative to $top_srcdir
|
||||
# $2 = final output filename, within the $1 directory
|
||||
#
|
||||
# This script must be run from the top-level build directory, and $top_srcdir
|
||||
# must be set correctly in the environment.
|
||||
#
|
||||
# This looks in $1, and uses all the *.mdd files there. Each .mdd file
|
||||
# defines one module. The .mdd file is actually a shell script, which will
|
||||
# be sourced. It may define the following shell variables:
|
||||
#
|
||||
# name name of this module
|
||||
# moddeps modules on which this module depends (default none)
|
||||
# nozshdep non-empty indicates no dependence on the `zsh/main' pseudo-module
|
||||
# alwayslink if non-empty, always link the module into the executable
|
||||
# autofeatures features defined by the module, for autoloading
|
||||
# autofeatures_emu As autofeatures, but for non-zsh emulation modes
|
||||
# objects .o files making up this module (*must* be defined)
|
||||
# proto .syms files for this module (default generated from $objects)
|
||||
# headers extra headers for this module (default none)
|
||||
# hdrdeps extra headers on which the .mdh depends (default none)
|
||||
# otherincs extra headers that are included indirectly (default none)
|
||||
#
|
||||
# The .mdd file may also include a Makefile.in fragment between lines
|
||||
# `:<<\Make' and `Make' -- this will be copied into Makemod.in.
|
||||
#
|
||||
# The resulting Makemod.in knows how to build each module that is defined.
|
||||
# For each module it also knows how to build a .mdh file. Each source file
|
||||
# should #include the .mdh file for the module it is a part of. The .mdh
|
||||
# file #includes the .mdh files for any module dependencies, then each of
|
||||
# $headers, and then each .epro (for global declarations). It will
|
||||
# be recreated if any of the dependency .mdh files changes, or if any of
|
||||
# $headers or $hdrdeps changes. When anything depends on it, all the .epros
|
||||
# and $otherincs will be made up to date, but the .mdh file won't actually
|
||||
# be rebuilt if those files change.
|
||||
#
|
||||
# The order of sections of the output file is thus:
|
||||
# simple generated macros
|
||||
# macros generated from *.mdd
|
||||
# included Makemod.in.in
|
||||
# rules generated from *.mdd
|
||||
# The order dependencies are basically that the generated macros are required
|
||||
# in Makemod.in.in, but some of the macros that it creates are needed in the
|
||||
# later rules.
|
||||
#
|
||||
|
||||
# sed script to normalise a pathname
|
||||
sed_normalise='
|
||||
s,^,/,
|
||||
s,$,/,
|
||||
:1
|
||||
s,/\./,/,
|
||||
t1
|
||||
:2
|
||||
s,/[^/.][^/]*/\.\./,/,
|
||||
s,/\.[^/.][^/]*/\.\./,/,
|
||||
s,/\.\.[^/][^/]*/\.\./,/,
|
||||
t2
|
||||
s,^/$,.,
|
||||
s,^/,,
|
||||
s,\(.\)/$,\1,
|
||||
'
|
||||
|
||||
# decide which stages to process
|
||||
first_stage=true
|
||||
second_stage=true
|
||||
if test ."$1" = .-m; then
|
||||
shift
|
||||
first_stage=false
|
||||
elif test ."$1" = .-i; then
|
||||
shift
|
||||
second_stage=false
|
||||
fi
|
||||
|
||||
top_srcdir=`echo $top_srcdir | sed "$sed_normalise"`
|
||||
the_subdir=$1
|
||||
the_makefile=$2
|
||||
|
||||
if $first_stage; then
|
||||
|
||||
dir_top=`echo $the_subdir | sed 's,[^/][^/]*,..,g'`
|
||||
|
||||
trap "rm -f $the_subdir/${the_makefile}.in; exit 1" 1 2 15
|
||||
echo "creating $the_subdir/${the_makefile}.in"
|
||||
exec 3>&1 >$the_subdir/${the_makefile}.in
|
||||
echo "##### ${the_makefile}.in generated automatically by mkmakemod.sh"
|
||||
echo "##### DO NOT EDIT!"
|
||||
echo
|
||||
echo "##### ===== DEFINITIONS ===== #####"
|
||||
echo
|
||||
echo "makefile = ${the_makefile}"
|
||||
echo "dir_top = ${dir_top}"
|
||||
echo "subdir = ${the_subdir}"
|
||||
echo
|
||||
|
||||
bin_mods=`grep link=static ./config.modules | \
|
||||
sed -e '/^#/d' -e 's/ .*/ /' -e 's/^name=/ /'`
|
||||
dyn_mods="`grep link=dynamic ./config.modules | \
|
||||
sed -e '/^#/d' -e 's/ .*/ /' -e 's/^name=/ /'`"
|
||||
module_list="${bin_mods}${dyn_mods}"
|
||||
|
||||
if grep '^#define DYNAMIC ' config.h >/dev/null; then
|
||||
is_dynamic=true
|
||||
else
|
||||
is_dynamic=false
|
||||
fi
|
||||
|
||||
here_mddnames=
|
||||
all_subdirs=
|
||||
all_modobjs=
|
||||
all_modules=
|
||||
all_mdds=
|
||||
all_mdhs=
|
||||
all_proto=
|
||||
lastsub=//
|
||||
for module in $module_list; do
|
||||
modfile="`grep '^name='$module' ' ./config.modules | \
|
||||
sed -e 's/^.* modfile=//' -e 's/ .*//'`"
|
||||
case $modfile in
|
||||
$the_subdir/$lastsub/*) ;;
|
||||
$the_subdir/*/*)
|
||||
lastsub=`echo $modfile | sed 's,^'$the_subdir'/,,;s,/[^/]*$,,'`
|
||||
case "$all_subdirs " in
|
||||
*" $lastsub "* ) ;;
|
||||
* )
|
||||
all_subdirs="$all_subdirs $lastsub"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
$the_subdir/*)
|
||||
mddname=`echo $modfile | sed 's,^.*/,,;s,\.mdd$,,'`
|
||||
here_mddnames="$here_mddnames $mddname"
|
||||
build=$is_dynamic
|
||||
case $is_dynamic@$bin_mods in
|
||||
*" $module "*)
|
||||
build=true
|
||||
all_modobjs="$all_modobjs modobjs.${mddname}" ;;
|
||||
true@*)
|
||||
all_modules="$all_modules ${mddname}.\$(DL_EXT)" ;;
|
||||
esac
|
||||
all_mdds="$all_mdds ${mddname}.mdd"
|
||||
$build && all_mdhs="$all_mdhs ${mddname}.mdh"
|
||||
$build && all_proto="$all_proto proto.${mddname}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "MODOBJS =$all_modobjs"
|
||||
echo "MODULES =$all_modules"
|
||||
echo "MDDS =$all_mdds"
|
||||
echo "MDHS =$all_mdhs"
|
||||
echo "PROTOS =$all_proto"
|
||||
echo "SUBDIRS =$all_subdirs"
|
||||
echo
|
||||
echo "ENTRYOBJ = \$(dir_src)/modentry..o"
|
||||
echo "NNTRYOBJ ="
|
||||
echo "ENTRYOPT = -emodentry"
|
||||
echo "NNTRYOPT ="
|
||||
echo
|
||||
|
||||
echo "##### ===== INCLUDING Makemod.in.in ===== #####"
|
||||
echo
|
||||
cat $top_srcdir/Src/Makemod.in.in
|
||||
echo
|
||||
|
||||
case $the_subdir in
|
||||
Src) modobjs_sed= ;;
|
||||
Src/*) modobjs_sed="| sed 's\" \" "`echo $the_subdir | sed 's,^Src/,,'`"/\"g' " ;;
|
||||
*) modobjs_sed="| sed 's\" \" ../$the_subdir/\"g' " ;;
|
||||
esac
|
||||
|
||||
other_mdhs=
|
||||
remote_mdhs=
|
||||
other_exports=
|
||||
remote_exports=
|
||||
other_modules=
|
||||
remote_modules=
|
||||
for mddname in $here_mddnames; do
|
||||
|
||||
unset name moddeps nozshdep alwayslink hasexport
|
||||
unset autofeatures autofeatures_emu
|
||||
unset objects proto headers hdrdeps otherincs
|
||||
. $top_srcdir/$the_subdir/${mddname}.mdd
|
||||
q_name=`echo $name | sed 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'`
|
||||
test -n "${moddeps+set}" || moddeps=
|
||||
test -n "$nozshdep" || moddeps="$moddeps zsh/main"
|
||||
test -n "${proto+set}" ||
|
||||
proto=`echo $objects '' | sed 's,\.o ,.syms ,g'`
|
||||
|
||||
dobjects=`echo $objects '' | sed 's,\.o ,..o ,g'`
|
||||
modhdeps=
|
||||
mododeps=
|
||||
exportdeps=
|
||||
imports=
|
||||
q_moddeps=
|
||||
for dep in $moddeps; do
|
||||
depfile="`grep '^name='$dep' ' ./config.modules | \
|
||||
sed -e 's/^.* modfile=//' -e 's/ .*//'`"
|
||||
q_dep=`echo $dep | sed 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'`
|
||||
q_moddeps="$q_moddeps $q_dep"
|
||||
eval `echo $depfile | sed 's,/\([^/]*\)\.mdd$,;depbase=\1,;s,^,loc=,'`
|
||||
case "$binmod" in
|
||||
*" $dep "* )
|
||||
dep=zsh/main
|
||||
;;
|
||||
esac
|
||||
|
||||
case $the_subdir in
|
||||
$loc)
|
||||
mdh="${depbase}.mdh"
|
||||
export="${depbase}.export"
|
||||
case "$dep" in
|
||||
zsh/main )
|
||||
mdll="\$(dir_top)/Src/libzsh-\$(VERSION).\$(DL_EXT) "
|
||||
;;
|
||||
* )
|
||||
mdll="${depbase}.\$(DL_EXT) "
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
$loc/*)
|
||||
mdh="\$(dir_top)/$loc/${depbase}.mdh"
|
||||
case "$other_mdhs " in
|
||||
*" $mdh "*) ;;
|
||||
*) other_mdhs="$other_mdhs $mdh" ;;
|
||||
esac
|
||||
export="\$(dir_top)/$loc/${depbase}.export"
|
||||
case "$other_exports " in
|
||||
*" $export "*) ;;
|
||||
*) other_exports="$other_exports $export" ;;
|
||||
esac
|
||||
case "$dep" in
|
||||
zsh/main )
|
||||
mdll="\$(dir_top)/Src/libzsh-\$(VERSION).\$(DL_EXT) "
|
||||
;;
|
||||
* )
|
||||
mdll="\$(dir_top)/$loc/${depbase}.\$(DL_EXT) "
|
||||
;;
|
||||
esac
|
||||
case "$other_modules " in
|
||||
*" $mdll "*) ;;
|
||||
*) other_modules="$other_modules $mdll" ;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
mdh="\$(dir_top)/$loc/${depbase}.mdh"
|
||||
case "$remote_mdhs " in
|
||||
*" $mdh "*) ;;
|
||||
*) remote_mdhs="$remote_mdhs $mdh" ;;
|
||||
esac
|
||||
export="\$(dir_top)/$loc/${depbase}.export"
|
||||
case "$remote_exports " in
|
||||
*" $export "*) ;;
|
||||
*) remote_exports="$remote_exports $export" ;;
|
||||
esac
|
||||
case "$dep" in
|
||||
zsh/main )
|
||||
mdll="\$(dir_top)/Src/libzsh-\$(VERSION).\$(DL_EXT) "
|
||||
;;
|
||||
* )
|
||||
mdll="\$(dir_top)/$loc/${depbase}.\$(DL_EXT) "
|
||||
;;
|
||||
esac
|
||||
case "$remote_modules " in
|
||||
*" $mdll "*) ;;
|
||||
*) remote_modules="$remote_modules $mdll" ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
modhdeps="$modhdeps $mdh"
|
||||
exportdeps="$exportdeps $export"
|
||||
imports="$imports \$(IMPOPT)$export"
|
||||
case "$mododeps " in
|
||||
*" $mdll "* )
|
||||
:
|
||||
;;
|
||||
* )
|
||||
mododeps="$mododeps $mdll"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "##### ===== DEPENDENCIES GENERATED FROM ${mddname}.mdd ===== #####"
|
||||
echo
|
||||
echo "MODOBJS_${mddname} = $objects"
|
||||
echo "MODDOBJS_${mddname} = $dobjects \$(@E@NTRYOBJ)"
|
||||
echo "SYMS_${mddname} = $proto"
|
||||
echo "EPRO_${mddname} = "`echo $proto '' | sed 's,\.syms ,.epro ,g'`
|
||||
echo "INCS_${mddname} = \$(EPRO_${mddname}) $otherincs"
|
||||
echo "EXPIMP_${mddname} = $imports \$(EXPOPT)$mddname.export"
|
||||
echo "NXPIMP_${mddname} ="
|
||||
echo "LINKMODS_${mddname} = $mododeps"
|
||||
echo "NOLINKMODS_${mddname} = "
|
||||
echo
|
||||
echo "proto.${mddname}: \$(EPRO_${mddname})"
|
||||
echo "\$(SYMS_${mddname}): \$(PROTODEPS)"
|
||||
echo
|
||||
echo "${mddname}.export: \$(SYMS_${mddname})"
|
||||
echo " @( echo '#!'; cat \$(SYMS_${mddname}) | sed -n '/^X/{s/^X//;p;}' | sort -u ) > \$@"
|
||||
echo
|
||||
echo "modobjs.${mddname}: \$(MODOBJS_${mddname})"
|
||||
echo " @echo '' \$(MODOBJS_${mddname}) $modobjs_sed>> \$(dir_src)/stamp-modobjs.tmp"
|
||||
echo
|
||||
if test -z "$alwayslink"; then
|
||||
case " $all_modules" in *" ${mddname}."*)
|
||||
echo "install.modules-here: install.modules.${mddname}"
|
||||
echo "uninstall.modules-here: uninstall.modules.${mddname}"
|
||||
echo
|
||||
;; esac
|
||||
instsubdir=`echo $name | sed 's,^,/,;s,/[^/]*$,,'`
|
||||
echo "install.modules.${mddname}: ${mddname}.\$(DL_EXT)"
|
||||
echo " \$(SHELL) \$(sdir_top)/mkinstalldirs \$(DESTDIR)\$(MODDIR)${instsubdir}"
|
||||
echo " \$(INSTALL_PROGRAM) \$(STRIPFLAGS) ${mddname}.\$(DL_EXT) \$(DESTDIR)\$(MODDIR)/${name}.\$(DL_EXT)"
|
||||
echo
|
||||
echo "uninstall.modules.${mddname}:"
|
||||
echo " rm -f \$(DESTDIR)\$(MODDIR)/${name}.\$(DL_EXT)"
|
||||
echo
|
||||
echo "${mddname}.\$(DL_EXT): \$(MODDOBJS_${mddname}) ${mddname}.export $exportdeps \$(@LINKMODS@_${mddname})"
|
||||
echo ' rm -f $@'
|
||||
echo " \$(DLLINK) \$(@E@XPIMP_$mddname) \$(@E@NTRYOPT) \$(MODDOBJS_${mddname}) \$(@LINKMODS@_${mddname}) \$(LIBS) "
|
||||
echo
|
||||
fi
|
||||
echo "${mddname}.mdhi: ${mddname}.mdhs \$(INCS_${mddname})"
|
||||
echo " @test -f \$@ || echo 'do not delete this file' > \$@"
|
||||
echo
|
||||
echo "${mddname}.mdhs: ${mddname}.mdd"
|
||||
echo " @\$(MAKE) -f \$(makefile) \$(MAKEDEFS) ${mddname}.mdh.tmp"
|
||||
echo " @if cmp -s ${mddname}.mdh ${mddname}.mdh.tmp; then \\"
|
||||
echo " rm -f ${mddname}.mdh.tmp; \\"
|
||||
echo " echo \"\\\`${mddname}.mdh' is up to date.\"; \\"
|
||||
echo " else \\"
|
||||
echo " mv -f ${mddname}.mdh.tmp ${mddname}.mdh; \\"
|
||||
echo " echo \"Updated \\\`${mddname}.mdh'.\"; \\"
|
||||
echo " fi"
|
||||
echo " echo 'timestamp for ${mddname}.mdh against ${mddname}.mdd' > \$@"
|
||||
echo
|
||||
echo "${mddname}.mdh: ${modhdeps} ${headers} ${hdrdeps} ${mddname}.mdhi"
|
||||
echo " @\$(MAKE) -f \$(makefile) \$(MAKEDEFS) ${mddname}.mdh.tmp"
|
||||
echo " @mv -f ${mddname}.mdh.tmp ${mddname}.mdh"
|
||||
echo " @echo \"Updated \\\`${mddname}.mdh'.\""
|
||||
echo
|
||||
echo "${mddname}.mdh.tmp:"
|
||||
echo " @( \\"
|
||||
echo " echo '#ifndef have_${q_name}_module'; \\"
|
||||
echo " echo '#define have_${q_name}_module'; \\"
|
||||
echo " echo; \\"
|
||||
echo " echo '# ifndef IMPORTING_MODULE_${q_name}'; \\"
|
||||
echo " if test @SHORTBOOTNAMES@ = yes; then \\"
|
||||
echo " echo '# ifndef MODULE'; \\"
|
||||
echo " fi; \\"
|
||||
echo " echo '# define boot_ boot_${q_name}'; \\"
|
||||
echo " echo '# define cleanup_ cleanup_${q_name}'; \\"
|
||||
echo " echo '# define features_ features_${q_name}'; \\"
|
||||
echo " echo '# define enables_ enables_${q_name}'; \\"
|
||||
echo " echo '# define setup_ setup_${q_name}'; \\"
|
||||
echo " echo '# define finish_ finish_${q_name}'; \\"
|
||||
echo " if test @SHORTBOOTNAMES@ = yes; then \\"
|
||||
echo " echo '# endif /* !MODULE */'; \\"
|
||||
echo " fi; \\"
|
||||
echo " echo '# endif /* !IMPORTING_MODULE_${q_name} */'; \\"
|
||||
echo " echo; \\"
|
||||
if test -n "$moddeps"; then (
|
||||
set x $q_moddeps
|
||||
echo " echo '/* Module dependencies */'; \\"
|
||||
for hdep in $modhdeps; do
|
||||
shift
|
||||
echo " echo '# define IMPORTING_MODULE_${1} 1'; \\"
|
||||
echo " echo '# include \"${hdep}\"'; \\"
|
||||
done
|
||||
echo " echo; \\"
|
||||
) fi
|
||||
if test -n "$headers"; then
|
||||
echo " echo '/* Extra headers for this module */'; \\"
|
||||
echo " for hdr in $headers; do \\"
|
||||
echo " echo '# include \"'\$\$hdr'\"'; \\"
|
||||
echo " done; \\"
|
||||
echo " echo; \\"
|
||||
fi
|
||||
if test -n "$proto"; then
|
||||
echo " echo '# undef mod_import_variable'; \\"
|
||||
echo " echo '# undef mod_import_function'; \\"
|
||||
echo " echo '# if defined(IMPORTING_MODULE_${q_name}) && defined(MODULE)'; \\"
|
||||
echo " echo '# define mod_import_variable @MOD_IMPORT_VARIABLE@'; \\"
|
||||
echo " echo '# define mod_import_function @MOD_IMPORT_FUNCTION@'; \\"
|
||||
echo " echo '# else'; \\"
|
||||
echo " echo '# define mod_import_function'; \\"
|
||||
echo " echo '# define mod_import_variable'; \\"
|
||||
echo " echo '# endif /* IMPORTING_MODULE_${q_name} && MODULE */'; \\"
|
||||
echo " for epro in \$(EPRO_${mddname}); do \\"
|
||||
echo " echo '# include \"'\$\$epro'\"'; \\"
|
||||
echo " done; \\"
|
||||
echo " echo '# undef mod_import_variable'; \\"
|
||||
echo " echo '# define mod_import_variable'; \\"
|
||||
echo " echo '# undef mod_import_variable'; \\"
|
||||
echo " echo '# define mod_import_variable'; \\"
|
||||
echo " echo '# ifndef mod_export'; \\"
|
||||
echo " echo '# define mod_export @MOD_EXPORT@'; \\"
|
||||
echo " echo '# endif /* mod_export */'; \\"
|
||||
echo " echo; \\"
|
||||
fi
|
||||
echo " echo '#endif /* !have_${q_name}_module */'; \\"
|
||||
echo " ) > \$@"
|
||||
echo
|
||||
echo "\$(MODOBJS_${mddname}) \$(MODDOBJS_${mddname}): ${mddname}.mdh"
|
||||
sed -e '/^ *: *<< *\\Make *$/,/^Make$/!d' \
|
||||
-e 's/^ *: *<< *\\Make *$//; /^Make$/d' \
|
||||
< $top_srcdir/$the_subdir/${mddname}.mdd
|
||||
echo
|
||||
|
||||
done
|
||||
|
||||
if test -n "$remote_mdhs$other_mdhs$remote_exports$other_exports$remote_modules$other_modules"; then
|
||||
echo "##### ===== DEPENDENCIES FOR REMOTE MODULES ===== #####"
|
||||
echo
|
||||
for mdh in $remote_mdhs; do
|
||||
echo "$mdh: FORCE"
|
||||
echo " @cd @%@ && \$(MAKE) \$(MAKEDEFS) @%@$mdh"
|
||||
echo
|
||||
done | sed 's,^\(.*\)@%@\(.*\)@%@\(.*\)/\([^/]*\)$,\1\3\2\4,'
|
||||
if test -n "$other_mdhs"; then
|
||||
echo "${other_mdhs}:" | sed 's,^ ,,'
|
||||
echo " false # A. should only happen with make -n"
|
||||
echo
|
||||
fi
|
||||
for export in $remote_exports; do
|
||||
echo "$export: FORCE"
|
||||
echo " @cd @%@ && \$(MAKE) \$(MAKEDEFS) @%@$export"
|
||||
echo
|
||||
done | sed 's,^\(.*\)@%@\(.*\)@%@\(.*\)/\([^/]*\)$,\1\3\2\4,'
|
||||
if test -n "$other_exports"; then
|
||||
echo "${other_exports}:" | sed 's,^ ,,'
|
||||
echo " false # B. should only happen with make -n"
|
||||
echo
|
||||
fi
|
||||
for mdll in $remote_modules; do
|
||||
echo "$mdll: FORCE"
|
||||
echo " @cd @%@ && \$(MAKE) \$(MAKEDEFS) @%@$mdll"
|
||||
echo
|
||||
done | sed 's,^\(.*\)@%@\(.*\)@%@\(.*\)/\([^/]*\)$,\1\3\2\4,'
|
||||
if test -n "$other_modules"; then
|
||||
echo "${other_modules}:" | sed 's,^ ,,'
|
||||
echo " false # C. should only happen with make -n"
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "##### End of ${the_makefile}.in"
|
||||
|
||||
exec >&3 3>&-
|
||||
|
||||
fi
|
||||
|
||||
if $second_stage ; then
|
||||
trap "rm -f $the_subdir/${the_makefile}; exit 1" 1 2 15
|
||||
|
||||
${CONFIG_SHELL-/bin/sh} ./config.status \
|
||||
--file=$the_subdir/${the_makefile}:$the_subdir/${the_makefile}.in ||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
3641
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/module.c
vendored
Normal file
3641
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/module.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
955
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/options.c
vendored
Normal file
955
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/options.c
vendored
Normal file
@ -0,0 +1,955 @@
|
||||
/*
|
||||
* options.c - shell options
|
||||
*
|
||||
* This file is part of zsh, the Z shell.
|
||||
*
|
||||
* Copyright (c) 1992-1997 Paul Falstad
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and to distribute modified versions of this software for any
|
||||
* purpose, provided that the above copyright notice and the following
|
||||
* two paragraphs appear in all copies of this software.
|
||||
*
|
||||
* In no event shall Paul Falstad or the Zsh Development Group be liable
|
||||
* to any party for direct, indirect, special, incidental, or consequential
|
||||
* damages arising out of the use of this software and its documentation,
|
||||
* even if Paul Falstad and the Zsh Development Group have been advised of
|
||||
* the possibility of such damage.
|
||||
*
|
||||
* Paul Falstad and the Zsh Development Group specifically disclaim any
|
||||
* warranties, including, but not limited to, the implied warranties of
|
||||
* merchantability and fitness for a particular purpose. The software
|
||||
* provided hereunder is on an "as is" basis, and Paul Falstad and the
|
||||
* Zsh Development Group have no obligation to provide maintenance,
|
||||
* support, updates, enhancements, or modifications.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "zsh.mdh"
|
||||
#include "options.pro"
|
||||
|
||||
/* current emulation (used to decide which set of option letters is used) */
|
||||
|
||||
/**/
|
||||
mod_export int emulation;
|
||||
|
||||
/* current sticky emulation: sticky = NULL means none */
|
||||
|
||||
/**/
|
||||
mod_export Emulation_options sticky;
|
||||
|
||||
/* the options; e.g. if opts[SHGLOB] != 0, SH_GLOB is turned on */
|
||||
|
||||
/**/
|
||||
mod_export char opts[OPT_SIZE];
|
||||
|
||||
/* Option name hash table */
|
||||
|
||||
/**/
|
||||
mod_export HashTable optiontab;
|
||||
|
||||
/* The canonical option name table */
|
||||
|
||||
#define OPT_CSH EMULATE_CSH
|
||||
#define OPT_KSH EMULATE_KSH
|
||||
#define OPT_SH EMULATE_SH
|
||||
#define OPT_ZSH EMULATE_ZSH
|
||||
|
||||
#define OPT_ALL (OPT_CSH|OPT_KSH|OPT_SH|OPT_ZSH)
|
||||
#define OPT_BOURNE (OPT_KSH|OPT_SH)
|
||||
#define OPT_BSHELL (OPT_KSH|OPT_SH|OPT_ZSH)
|
||||
#define OPT_NONBOURNE (OPT_ALL & ~OPT_BOURNE)
|
||||
#define OPT_NONZSH (OPT_ALL & ~OPT_ZSH)
|
||||
|
||||
/* option is relevant to emulation */
|
||||
#define OPT_EMULATE (EMULATE_UNUSED)
|
||||
/* option should never be set by emulate() */
|
||||
#define OPT_SPECIAL (EMULATE_UNUSED<<1)
|
||||
/* option is an alias to an other option */
|
||||
#define OPT_ALIAS (EMULATE_UNUSED<<2)
|
||||
|
||||
#define defset(X, my_emulation) (!!((X)->node.flags & my_emulation))
|
||||
|
||||
/*
|
||||
* Note that option names should usually be fewer than 20 characters long
|
||||
* to avoid formatting problems.
|
||||
*/
|
||||
static struct optname optns[] = {
|
||||
{{NULL, "aliases", OPT_EMULATE|OPT_ALL}, ALIASESOPT},
|
||||
{{NULL, "aliasfuncdef", OPT_EMULATE|OPT_BOURNE}, ALIASFUNCDEF},
|
||||
{{NULL, "allexport", OPT_EMULATE}, ALLEXPORT},
|
||||
{{NULL, "alwayslastprompt", OPT_ALL}, ALWAYSLASTPROMPT},
|
||||
{{NULL, "alwaystoend", 0}, ALWAYSTOEND},
|
||||
{{NULL, "appendcreate", OPT_EMULATE|OPT_BOURNE}, APPENDCREATE},
|
||||
{{NULL, "appendhistory", OPT_ALL}, APPENDHISTORY},
|
||||
{{NULL, "autocd", OPT_EMULATE}, AUTOCD},
|
||||
{{NULL, "autocontinue", 0}, AUTOCONTINUE},
|
||||
{{NULL, "autolist", OPT_ALL}, AUTOLIST},
|
||||
{{NULL, "automenu", OPT_ALL}, AUTOMENU},
|
||||
{{NULL, "autonamedirs", 0}, AUTONAMEDIRS},
|
||||
{{NULL, "autoparamkeys", OPT_ALL}, AUTOPARAMKEYS},
|
||||
{{NULL, "autoparamslash", OPT_ALL}, AUTOPARAMSLASH},
|
||||
{{NULL, "autopushd", 0}, AUTOPUSHD},
|
||||
{{NULL, "autoremoveslash", OPT_ALL}, AUTOREMOVESLASH},
|
||||
{{NULL, "autoresume", 0}, AUTORESUME},
|
||||
{{NULL, "badpattern", OPT_EMULATE|OPT_NONBOURNE},BADPATTERN},
|
||||
{{NULL, "banghist", OPT_NONBOURNE}, BANGHIST},
|
||||
{{NULL, "bareglobqual", OPT_EMULATE|OPT_ZSH}, BAREGLOBQUAL},
|
||||
{{NULL, "bashautolist", 0}, BASHAUTOLIST},
|
||||
{{NULL, "bashrematch", 0}, BASHREMATCH},
|
||||
{{NULL, "beep", OPT_ALL}, BEEP},
|
||||
{{NULL, "bgnice", OPT_EMULATE|OPT_NONBOURNE},BGNICE},
|
||||
{{NULL, "braceccl", OPT_EMULATE}, BRACECCL},
|
||||
{{NULL, "bsdecho", OPT_EMULATE|OPT_SH}, BSDECHO},
|
||||
{{NULL, "caseglob", OPT_ALL}, CASEGLOB},
|
||||
{{NULL, "casematch", OPT_ALL}, CASEMATCH},
|
||||
{{NULL, "cbases", 0}, CBASES},
|
||||
{{NULL, "cprecedences", OPT_EMULATE|OPT_NONZSH}, CPRECEDENCES},
|
||||
{{NULL, "cdablevars", OPT_EMULATE}, CDABLEVARS},
|
||||
{{NULL, "chasedots", OPT_EMULATE}, CHASEDOTS},
|
||||
{{NULL, "chaselinks", OPT_EMULATE}, CHASELINKS},
|
||||
{{NULL, "checkjobs", OPT_EMULATE|OPT_ZSH}, CHECKJOBS},
|
||||
{{NULL, "checkrunningjobs", OPT_EMULATE|OPT_ZSH}, CHECKRUNNINGJOBS},
|
||||
{{NULL, "clobber", OPT_EMULATE|OPT_ALL}, CLOBBER},
|
||||
{{NULL, "combiningchars", 0}, COMBININGCHARS},
|
||||
{{NULL, "completealiases", 0}, COMPLETEALIASES},
|
||||
{{NULL, "completeinword", 0}, COMPLETEINWORD},
|
||||
{{NULL, "continueonerror", 0}, CONTINUEONERROR},
|
||||
{{NULL, "correct", 0}, CORRECT},
|
||||
{{NULL, "correctall", 0}, CORRECTALL},
|
||||
{{NULL, "cshjunkiehistory", OPT_EMULATE|OPT_CSH}, CSHJUNKIEHISTORY},
|
||||
{{NULL, "cshjunkieloops", OPT_EMULATE|OPT_CSH}, CSHJUNKIELOOPS},
|
||||
{{NULL, "cshjunkiequotes", OPT_EMULATE|OPT_CSH}, CSHJUNKIEQUOTES},
|
||||
{{NULL, "cshnullcmd", OPT_EMULATE|OPT_CSH}, CSHNULLCMD},
|
||||
{{NULL, "cshnullglob", OPT_EMULATE|OPT_CSH}, CSHNULLGLOB},
|
||||
{{NULL, "debugbeforecmd", OPT_ALL}, DEBUGBEFORECMD},
|
||||
{{NULL, "emacs", 0}, EMACSMODE},
|
||||
{{NULL, "equals", OPT_EMULATE|OPT_ZSH}, EQUALS},
|
||||
{{NULL, "errexit", OPT_EMULATE}, ERREXIT},
|
||||
{{NULL, "errreturn", OPT_EMULATE}, ERRRETURN},
|
||||
{{NULL, "exec", OPT_ALL}, EXECOPT},
|
||||
{{NULL, "extendedglob", OPT_EMULATE}, EXTENDEDGLOB},
|
||||
{{NULL, "extendedhistory", OPT_CSH}, EXTENDEDHISTORY},
|
||||
{{NULL, "evallineno", OPT_EMULATE|OPT_ZSH}, EVALLINENO},
|
||||
{{NULL, "flowcontrol", OPT_ALL}, FLOWCONTROL},
|
||||
{{NULL, "forcefloat", 0}, FORCEFLOAT},
|
||||
{{NULL, "functionargzero", OPT_EMULATE|OPT_NONBOURNE},FUNCTIONARGZERO},
|
||||
{{NULL, "glob", OPT_EMULATE|OPT_ALL}, GLOBOPT},
|
||||
{{NULL, "globalexport", OPT_EMULATE|OPT_ZSH}, GLOBALEXPORT},
|
||||
{{NULL, "globalrcs", OPT_ALL}, GLOBALRCS},
|
||||
{{NULL, "globassign", OPT_EMULATE|OPT_CSH}, GLOBASSIGN},
|
||||
{{NULL, "globcomplete", 0}, GLOBCOMPLETE},
|
||||
{{NULL, "globdots", OPT_EMULATE}, GLOBDOTS},
|
||||
{{NULL, "globstarshort", OPT_EMULATE}, GLOBSTARSHORT},
|
||||
{{NULL, "globsubst", OPT_EMULATE|OPT_NONZSH}, GLOBSUBST},
|
||||
{{NULL, "hashcmds", OPT_ALL}, HASHCMDS},
|
||||
{{NULL, "hashdirs", OPT_ALL}, HASHDIRS},
|
||||
{{NULL, "hashexecutablesonly", 0}, HASHEXECUTABLESONLY},
|
||||
{{NULL, "hashlistall", OPT_ALL}, HASHLISTALL},
|
||||
{{NULL, "histallowclobber", 0}, HISTALLOWCLOBBER},
|
||||
{{NULL, "histbeep", OPT_ALL}, HISTBEEP},
|
||||
{{NULL, "histexpiredupsfirst",0}, HISTEXPIREDUPSFIRST},
|
||||
{{NULL, "histfcntllock", 0}, HISTFCNTLLOCK},
|
||||
{{NULL, "histfindnodups", 0}, HISTFINDNODUPS},
|
||||
{{NULL, "histignorealldups", 0}, HISTIGNOREALLDUPS},
|
||||
{{NULL, "histignoredups", 0}, HISTIGNOREDUPS},
|
||||
{{NULL, "histignorespace", 0}, HISTIGNORESPACE},
|
||||
{{NULL, "histlexwords", 0}, HISTLEXWORDS},
|
||||
{{NULL, "histnofunctions", 0}, HISTNOFUNCTIONS},
|
||||
{{NULL, "histnostore", 0}, HISTNOSTORE},
|
||||
{{NULL, "histsubstpattern", OPT_EMULATE}, HISTSUBSTPATTERN},
|
||||
{{NULL, "histreduceblanks", 0}, HISTREDUCEBLANKS},
|
||||
{{NULL, "histsavebycopy", OPT_ALL}, HISTSAVEBYCOPY},
|
||||
{{NULL, "histsavenodups", 0}, HISTSAVENODUPS},
|
||||
{{NULL, "histverify", 0}, HISTVERIFY},
|
||||
{{NULL, "hup", OPT_EMULATE|OPT_ZSH}, HUP},
|
||||
{{NULL, "ignorebraces", OPT_EMULATE|OPT_SH}, IGNOREBRACES},
|
||||
{{NULL, "ignoreclosebraces", OPT_EMULATE}, IGNORECLOSEBRACES},
|
||||
{{NULL, "ignoreeof", 0}, IGNOREEOF},
|
||||
{{NULL, "incappendhistory", 0}, INCAPPENDHISTORY},
|
||||
{{NULL, "incappendhistorytime", 0}, INCAPPENDHISTORYTIME},
|
||||
{{NULL, "interactive", OPT_SPECIAL}, INTERACTIVE},
|
||||
{{NULL, "interactivecomments",OPT_BOURNE}, INTERACTIVECOMMENTS},
|
||||
{{NULL, "ksharrays", OPT_EMULATE|OPT_BOURNE}, KSHARRAYS},
|
||||
{{NULL, "kshautoload", OPT_EMULATE|OPT_BOURNE}, KSHAUTOLOAD},
|
||||
{{NULL, "kshglob", OPT_EMULATE|OPT_KSH}, KSHGLOB},
|
||||
{{NULL, "kshoptionprint", OPT_EMULATE|OPT_KSH}, KSHOPTIONPRINT},
|
||||
{{NULL, "kshtypeset", 0}, KSHTYPESET},
|
||||
{{NULL, "kshzerosubscript", 0}, KSHZEROSUBSCRIPT},
|
||||
{{NULL, "listambiguous", OPT_ALL}, LISTAMBIGUOUS},
|
||||
{{NULL, "listbeep", OPT_ALL}, LISTBEEP},
|
||||
{{NULL, "listpacked", 0}, LISTPACKED},
|
||||
{{NULL, "listrowsfirst", 0}, LISTROWSFIRST},
|
||||
{{NULL, "listtypes", OPT_ALL}, LISTTYPES},
|
||||
{{NULL, "localoptions", OPT_EMULATE|OPT_KSH}, LOCALOPTIONS},
|
||||
{{NULL, "localloops", OPT_EMULATE}, LOCALLOOPS},
|
||||
{{NULL, "localpatterns", OPT_EMULATE}, LOCALPATTERNS},
|
||||
{{NULL, "localtraps", OPT_EMULATE|OPT_KSH}, LOCALTRAPS},
|
||||
{{NULL, "login", OPT_SPECIAL}, LOGINSHELL},
|
||||
{{NULL, "longlistjobs", 0}, LONGLISTJOBS},
|
||||
{{NULL, "magicequalsubst", OPT_EMULATE}, MAGICEQUALSUBST},
|
||||
{{NULL, "mailwarning", 0}, MAILWARNING},
|
||||
{{NULL, "markdirs", 0}, MARKDIRS},
|
||||
{{NULL, "menucomplete", 0}, MENUCOMPLETE},
|
||||
{{NULL, "monitor", OPT_SPECIAL}, MONITOR},
|
||||
{{NULL, "multibyte",
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
OPT_ALL
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
}, MULTIBYTE},
|
||||
{{NULL, "multifuncdef", OPT_EMULATE|OPT_ZSH}, MULTIFUNCDEF},
|
||||
{{NULL, "multios", OPT_EMULATE|OPT_ZSH}, MULTIOS},
|
||||
{{NULL, "nomatch", OPT_EMULATE|OPT_NONBOURNE},NOMATCH},
|
||||
{{NULL, "notify", OPT_ZSH}, NOTIFY},
|
||||
{{NULL, "nullglob", OPT_EMULATE}, NULLGLOB},
|
||||
{{NULL, "numericglobsort", OPT_EMULATE}, NUMERICGLOBSORT},
|
||||
{{NULL, "octalzeroes", OPT_EMULATE|OPT_SH}, OCTALZEROES},
|
||||
{{NULL, "overstrike", 0}, OVERSTRIKE},
|
||||
{{NULL, "pathdirs", OPT_EMULATE}, PATHDIRS},
|
||||
{{NULL, "pathscript", OPT_EMULATE|OPT_BOURNE}, PATHSCRIPT},
|
||||
{{NULL, "pipefail", OPT_EMULATE}, PIPEFAIL},
|
||||
{{NULL, "posixaliases", OPT_EMULATE|OPT_BOURNE}, POSIXALIASES},
|
||||
{{NULL, "posixargzero", OPT_EMULATE}, POSIXARGZERO},
|
||||
{{NULL, "posixbuiltins", OPT_EMULATE|OPT_BOURNE}, POSIXBUILTINS},
|
||||
{{NULL, "posixcd", OPT_EMULATE|OPT_BOURNE}, POSIXCD},
|
||||
{{NULL, "posixidentifiers", OPT_EMULATE|OPT_BOURNE}, POSIXIDENTIFIERS},
|
||||
{{NULL, "posixjobs", OPT_EMULATE|OPT_BOURNE}, POSIXJOBS},
|
||||
{{NULL, "posixstrings", OPT_EMULATE|OPT_BOURNE}, POSIXSTRINGS},
|
||||
{{NULL, "posixtraps", OPT_EMULATE|OPT_BOURNE}, POSIXTRAPS},
|
||||
{{NULL, "printeightbit", 0}, PRINTEIGHTBIT},
|
||||
{{NULL, "printexitvalue", 0}, PRINTEXITVALUE},
|
||||
{{NULL, "privileged", OPT_SPECIAL}, PRIVILEGED},
|
||||
{{NULL, "promptbang", OPT_KSH}, PROMPTBANG},
|
||||
{{NULL, "promptcr", OPT_ALL}, PROMPTCR},
|
||||
{{NULL, "promptpercent", OPT_NONBOURNE}, PROMPTPERCENT},
|
||||
{{NULL, "promptsp", OPT_ALL}, PROMPTSP},
|
||||
{{NULL, "promptsubst", OPT_BOURNE}, PROMPTSUBST},
|
||||
{{NULL, "pushdignoredups", OPT_EMULATE}, PUSHDIGNOREDUPS},
|
||||
{{NULL, "pushdminus", OPT_EMULATE}, PUSHDMINUS},
|
||||
{{NULL, "pushdsilent", 0}, PUSHDSILENT},
|
||||
{{NULL, "pushdtohome", OPT_EMULATE}, PUSHDTOHOME},
|
||||
{{NULL, "rcexpandparam", OPT_EMULATE}, RCEXPANDPARAM},
|
||||
{{NULL, "rcquotes", OPT_EMULATE}, RCQUOTES},
|
||||
{{NULL, "rcs", OPT_ALL}, RCS},
|
||||
{{NULL, "recexact", 0}, RECEXACT},
|
||||
{{NULL, "rematchpcre", 0}, REMATCHPCRE},
|
||||
{{NULL, "restricted", OPT_SPECIAL}, RESTRICTED},
|
||||
{{NULL, "rmstarsilent", OPT_BOURNE}, RMSTARSILENT},
|
||||
{{NULL, "rmstarwait", 0}, RMSTARWAIT},
|
||||
{{NULL, "sharehistory", OPT_KSH}, SHAREHISTORY},
|
||||
{{NULL, "shfileexpansion", OPT_EMULATE|OPT_BOURNE}, SHFILEEXPANSION},
|
||||
{{NULL, "shglob", OPT_EMULATE|OPT_BOURNE}, SHGLOB},
|
||||
{{NULL, "shinstdin", OPT_SPECIAL}, SHINSTDIN},
|
||||
{{NULL, "shnullcmd", OPT_EMULATE|OPT_BOURNE}, SHNULLCMD},
|
||||
{{NULL, "shoptionletters", OPT_EMULATE|OPT_BOURNE}, SHOPTIONLETTERS},
|
||||
{{NULL, "shortloops", OPT_EMULATE|OPT_NONBOURNE},SHORTLOOPS},
|
||||
{{NULL, "shwordsplit", OPT_EMULATE|OPT_BOURNE}, SHWORDSPLIT},
|
||||
{{NULL, "singlecommand", OPT_SPECIAL}, SINGLECOMMAND},
|
||||
{{NULL, "singlelinezle", OPT_KSH}, SINGLELINEZLE},
|
||||
{{NULL, "sourcetrace", 0}, SOURCETRACE},
|
||||
{{NULL, "sunkeyboardhack", 0}, SUNKEYBOARDHACK},
|
||||
{{NULL, "transientrprompt", 0}, TRANSIENTRPROMPT},
|
||||
{{NULL, "trapsasync", 0}, TRAPSASYNC},
|
||||
{{NULL, "typesetsilent", OPT_EMULATE|OPT_BOURNE}, TYPESETSILENT},
|
||||
{{NULL, "unset", OPT_EMULATE|OPT_BSHELL}, UNSET},
|
||||
{{NULL, "verbose", 0}, VERBOSE},
|
||||
{{NULL, "vi", 0}, VIMODE},
|
||||
{{NULL, "warncreateglobal", OPT_EMULATE}, WARNCREATEGLOBAL},
|
||||
{{NULL, "warnnestedvar", OPT_EMULATE}, WARNNESTEDVAR},
|
||||
{{NULL, "xtrace", 0}, XTRACE},
|
||||
{{NULL, "zle", OPT_SPECIAL}, USEZLE},
|
||||
{{NULL, "braceexpand", OPT_ALIAS}, /* ksh/bash */ -IGNOREBRACES},
|
||||
{{NULL, "dotglob", OPT_ALIAS}, /* bash */ GLOBDOTS},
|
||||
{{NULL, "hashall", OPT_ALIAS}, /* bash */ HASHCMDS},
|
||||
{{NULL, "histappend", OPT_ALIAS}, /* bash */ APPENDHISTORY},
|
||||
{{NULL, "histexpand", OPT_ALIAS}, /* bash */ BANGHIST},
|
||||
{{NULL, "log", OPT_ALIAS}, /* ksh */ -HISTNOFUNCTIONS},
|
||||
{{NULL, "mailwarn", OPT_ALIAS}, /* bash */ MAILWARNING},
|
||||
{{NULL, "onecmd", OPT_ALIAS}, /* bash */ SINGLECOMMAND},
|
||||
{{NULL, "physical", OPT_ALIAS}, /* ksh/bash */ CHASELINKS},
|
||||
{{NULL, "promptvars", OPT_ALIAS}, /* bash */ PROMPTSUBST},
|
||||
{{NULL, "stdin", OPT_ALIAS}, /* ksh */ SHINSTDIN},
|
||||
{{NULL, "trackall", OPT_ALIAS}, /* ksh */ HASHCMDS},
|
||||
{{NULL, "dvorak", 0}, DVORAK},
|
||||
{{NULL, NULL, 0}, 0}
|
||||
};
|
||||
|
||||
/* Option letters */
|
||||
|
||||
#define optletters (isset(SHOPTIONLETTERS) ? kshletters : zshletters)
|
||||
|
||||
#define FIRST_OPT '0'
|
||||
#define LAST_OPT 'y'
|
||||
|
||||
static short zshletters[LAST_OPT - FIRST_OPT + 1] = {
|
||||
/* 0 */ CORRECT,
|
||||
/* 1 */ PRINTEXITVALUE,
|
||||
/* 2 */ -BADPATTERN,
|
||||
/* 3 */ -NOMATCH,
|
||||
/* 4 */ GLOBDOTS,
|
||||
/* 5 */ NOTIFY,
|
||||
/* 6 */ BGNICE,
|
||||
/* 7 */ IGNOREEOF,
|
||||
/* 8 */ MARKDIRS,
|
||||
/* 9 */ AUTOLIST,
|
||||
/* : */ 0,
|
||||
/* ; */ 0,
|
||||
/* < */ 0,
|
||||
/* = */ 0,
|
||||
/* > */ 0,
|
||||
/* ? */ 0,
|
||||
/* @ */ 0,
|
||||
/* A */ 0, /* use with set for arrays */
|
||||
/* B */ -BEEP,
|
||||
/* C */ -CLOBBER,
|
||||
/* D */ PUSHDTOHOME,
|
||||
/* E */ PUSHDSILENT,
|
||||
/* F */ -GLOBOPT,
|
||||
/* G */ NULLGLOB,
|
||||
/* H */ RMSTARSILENT,
|
||||
/* I */ IGNOREBRACES,
|
||||
/* J */ AUTOCD,
|
||||
/* K */ -BANGHIST,
|
||||
/* L */ SUNKEYBOARDHACK,
|
||||
/* M */ SINGLELINEZLE,
|
||||
/* N */ AUTOPUSHD,
|
||||
/* O */ CORRECTALL,
|
||||
/* P */ RCEXPANDPARAM,
|
||||
/* Q */ PATHDIRS,
|
||||
/* R */ LONGLISTJOBS,
|
||||
/* S */ RECEXACT,
|
||||
/* T */ CDABLEVARS,
|
||||
/* U */ MAILWARNING,
|
||||
/* V */ -PROMPTCR,
|
||||
/* W */ AUTORESUME,
|
||||
/* X */ LISTTYPES,
|
||||
/* Y */ MENUCOMPLETE,
|
||||
/* Z */ USEZLE,
|
||||
/* [ */ 0,
|
||||
/* \ */ 0,
|
||||
/* ] */ 0,
|
||||
/* ^ */ 0,
|
||||
/* _ */ 0,
|
||||
/* ` */ 0,
|
||||
/* a */ ALLEXPORT,
|
||||
/* b */ 0, /* in non-Bourne shells, end of options */
|
||||
/* c */ 0, /* command follows */
|
||||
/* d */ -GLOBALRCS,
|
||||
/* e */ ERREXIT,
|
||||
/* f */ -RCS,
|
||||
/* g */ HISTIGNORESPACE,
|
||||
/* h */ HISTIGNOREDUPS,
|
||||
/* i */ INTERACTIVE,
|
||||
/* j */ 0,
|
||||
/* k */ INTERACTIVECOMMENTS,
|
||||
/* l */ LOGINSHELL,
|
||||
/* m */ MONITOR,
|
||||
/* n */ -EXECOPT,
|
||||
/* o */ 0, /* long option name follows */
|
||||
/* p */ PRIVILEGED,
|
||||
/* q */ 0,
|
||||
/* r */ RESTRICTED,
|
||||
/* s */ SHINSTDIN,
|
||||
/* t */ SINGLECOMMAND,
|
||||
/* u */ -UNSET,
|
||||
/* v */ VERBOSE,
|
||||
/* w */ CHASELINKS,
|
||||
/* x */ XTRACE,
|
||||
/* y */ SHWORDSPLIT,
|
||||
};
|
||||
|
||||
static short kshletters[LAST_OPT - FIRST_OPT + 1] = {
|
||||
/* 0 */ 0,
|
||||
/* 1 */ 0,
|
||||
/* 2 */ 0,
|
||||
/* 3 */ 0,
|
||||
/* 4 */ 0,
|
||||
/* 5 */ 0,
|
||||
/* 6 */ 0,
|
||||
/* 7 */ 0,
|
||||
/* 8 */ 0,
|
||||
/* 9 */ 0,
|
||||
/* : */ 0,
|
||||
/* ; */ 0,
|
||||
/* < */ 0,
|
||||
/* = */ 0,
|
||||
/* > */ 0,
|
||||
/* ? */ 0,
|
||||
/* @ */ 0,
|
||||
/* A */ 0,
|
||||
/* B */ 0,
|
||||
/* C */ -CLOBBER,
|
||||
/* D */ 0,
|
||||
/* E */ 0,
|
||||
/* F */ 0,
|
||||
/* G */ 0,
|
||||
/* H */ 0,
|
||||
/* I */ 0,
|
||||
/* J */ 0,
|
||||
/* K */ 0,
|
||||
/* L */ 0,
|
||||
/* M */ 0,
|
||||
/* N */ 0,
|
||||
/* O */ 0,
|
||||
/* P */ 0,
|
||||
/* Q */ 0,
|
||||
/* R */ 0,
|
||||
/* S */ 0,
|
||||
/* T */ TRAPSASYNC,
|
||||
/* U */ 0,
|
||||
/* V */ 0,
|
||||
/* W */ 0,
|
||||
/* X */ MARKDIRS,
|
||||
/* Y */ 0,
|
||||
/* Z */ 0,
|
||||
/* [ */ 0,
|
||||
/* \ */ 0,
|
||||
/* ] */ 0,
|
||||
/* ^ */ 0,
|
||||
/* _ */ 0,
|
||||
/* ` */ 0,
|
||||
/* a */ ALLEXPORT,
|
||||
/* b */ NOTIFY,
|
||||
/* c */ 0,
|
||||
/* d */ 0,
|
||||
/* e */ ERREXIT,
|
||||
/* f */ -GLOBOPT,
|
||||
/* g */ 0,
|
||||
/* h */ 0,
|
||||
/* i */ INTERACTIVE,
|
||||
/* j */ 0,
|
||||
/* k */ 0,
|
||||
/* l */ LOGINSHELL,
|
||||
/* m */ MONITOR,
|
||||
/* n */ -EXECOPT,
|
||||
/* o */ 0,
|
||||
/* p */ PRIVILEGED,
|
||||
/* q */ 0,
|
||||
/* r */ RESTRICTED,
|
||||
/* s */ SHINSTDIN,
|
||||
/* t */ SINGLECOMMAND,
|
||||
/* u */ -UNSET,
|
||||
/* v */ VERBOSE,
|
||||
/* w */ 0,
|
||||
/* x */ XTRACE,
|
||||
/* y */ 0,
|
||||
};
|
||||
|
||||
/* Initialisation of the option name hash table */
|
||||
|
||||
/**/
|
||||
static void
|
||||
printoptionnode(HashNode hn, int set)
|
||||
{
|
||||
Optname on = (Optname) hn;
|
||||
int optno = on->optno;
|
||||
|
||||
if (optno < 0)
|
||||
optno = -optno;
|
||||
if (isset(KSHOPTIONPRINT)) {
|
||||
if (defset(on, emulation))
|
||||
printf("no%-19s %s\n", on->node.nam, isset(optno) ? "off" : "on");
|
||||
else
|
||||
printf("%-21s %s\n", on->node.nam, isset(optno) ? "on" : "off");
|
||||
} else if (set == (isset(optno) ^ defset(on, emulation))) {
|
||||
if (set ^ isset(optno))
|
||||
fputs("no", stdout);
|
||||
puts(on->node.nam);
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
void
|
||||
createoptiontable(void)
|
||||
{
|
||||
Optname on;
|
||||
|
||||
optiontab = newhashtable(101, "optiontab", NULL);
|
||||
|
||||
optiontab->hash = hasher;
|
||||
optiontab->emptytable = NULL;
|
||||
optiontab->filltable = NULL;
|
||||
optiontab->cmpnodes = strcmp;
|
||||
optiontab->addnode = addhashnode;
|
||||
optiontab->getnode = gethashnode;
|
||||
optiontab->getnode2 = gethashnode2;
|
||||
optiontab->removenode = NULL;
|
||||
optiontab->disablenode = disablehashnode;
|
||||
optiontab->enablenode = enablehashnode;
|
||||
optiontab->freenode = NULL;
|
||||
optiontab->printnode = printoptionnode;
|
||||
|
||||
for (on = optns; on->node.nam; on++)
|
||||
optiontab->addnode(optiontab, on->node.nam, on);
|
||||
}
|
||||
|
||||
/* Emulation appropriate to the setemulate function */
|
||||
|
||||
static int setemulate_emulation;
|
||||
|
||||
/* Option array manipulated within the setemulate function */
|
||||
|
||||
/**/
|
||||
static char *setemulate_opts;
|
||||
|
||||
/* Setting of default options */
|
||||
|
||||
/**/
|
||||
static void
|
||||
setemulate(HashNode hn, int fully)
|
||||
{
|
||||
Optname on = (Optname) hn;
|
||||
|
||||
/* Set options: each non-special option is set according to the *
|
||||
* current emulation mode if either it is considered relevant *
|
||||
* to emulation or we are doing a full emulation (as indicated *
|
||||
* by the `fully' parameter). */
|
||||
if (!(on->node.flags & OPT_ALIAS) &&
|
||||
((fully && !(on->node.flags & OPT_SPECIAL)) ||
|
||||
(on->node.flags & OPT_EMULATE)))
|
||||
setemulate_opts[on->optno] = defset(on, setemulate_emulation);
|
||||
}
|
||||
|
||||
/**/
|
||||
void
|
||||
installemulation(int new_emulation, char *new_opts)
|
||||
{
|
||||
setemulate_emulation = new_emulation;
|
||||
setemulate_opts = new_opts;
|
||||
scanhashtable(optiontab, 0, 0, 0, setemulate,
|
||||
!!(new_emulation & EMULATE_FULLY));
|
||||
}
|
||||
|
||||
/**/
|
||||
void
|
||||
emulate(const char *zsh_name, int fully, int *new_emulation, char *new_opts)
|
||||
{
|
||||
char ch = *zsh_name;
|
||||
|
||||
if (ch == 'r')
|
||||
ch = zsh_name[1];
|
||||
|
||||
/* Work out the new emulation mode */
|
||||
if (ch == 'c')
|
||||
*new_emulation = EMULATE_CSH;
|
||||
else if (ch == 'k')
|
||||
*new_emulation = EMULATE_KSH;
|
||||
else if (ch == 's' || ch == 'b')
|
||||
*new_emulation = EMULATE_SH;
|
||||
else
|
||||
*new_emulation = EMULATE_ZSH;
|
||||
|
||||
if (fully)
|
||||
*new_emulation |= EMULATE_FULLY;
|
||||
installemulation(*new_emulation, new_opts);
|
||||
|
||||
if (funcstack && funcstack->tp == FS_FUNC) {
|
||||
/*
|
||||
* We are inside a function. Decide if it's traced.
|
||||
* Pedantic note: the function in the function table isn't
|
||||
* guaranteed to be what we're executing, but it's
|
||||
* close enough.
|
||||
*/
|
||||
Shfunc shf = (Shfunc)shfunctab->getnode(shfunctab, funcstack->name);
|
||||
if (shf && (shf->node.flags & (PM_TAGGED|PM_TAGGED_LOCAL))) {
|
||||
/* Tracing is on, so set xtrace */
|
||||
new_opts[XTRACE] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* setopt, unsetopt */
|
||||
|
||||
/**/
|
||||
static void
|
||||
setoption(HashNode hn, int value)
|
||||
{
|
||||
dosetopt(((Optname) hn)->optno, value, 0, opts);
|
||||
}
|
||||
|
||||
/**/
|
||||
int
|
||||
bin_setopt(char *nam, char **args, UNUSED(Options ops), int isun)
|
||||
{
|
||||
int action, optno, match = 0;
|
||||
|
||||
/* With no arguments or options, display options. */
|
||||
if (!*args) {
|
||||
scanhashtable(optiontab, 1, 0, OPT_ALIAS, optiontab->printnode, !isun);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* loop through command line options (begins with "-" or "+") */
|
||||
while (*args && (**args == '-' || **args == '+')) {
|
||||
action = (**args == '-') ^ isun;
|
||||
if(!args[0][1])
|
||||
*args = "--";
|
||||
while (*++*args) {
|
||||
if(**args == Meta)
|
||||
*++*args ^= 32;
|
||||
/* The pseudo-option `--' signifies the end of options. */
|
||||
if (**args == '-') {
|
||||
args++;
|
||||
goto doneoptions;
|
||||
} else if (**args == 'o') {
|
||||
if (!*++*args)
|
||||
args++;
|
||||
if (!*args) {
|
||||
zwarnnam(nam, "string expected after -o");
|
||||
inittyptab();
|
||||
return 1;
|
||||
}
|
||||
if(!(optno = optlookup(*args)))
|
||||
zwarnnam(nam, "no such option: %s", *args);
|
||||
else if(dosetopt(optno, action, 0, opts))
|
||||
zwarnnam(nam, "can't change option: %s", *args);
|
||||
break;
|
||||
} else if(**args == 'm') {
|
||||
match = 1;
|
||||
} else {
|
||||
if (!(optno = optlookupc(**args)))
|
||||
zwarnnam(nam, "bad option: -%c", **args);
|
||||
else if(dosetopt(optno, action, 0, opts))
|
||||
zwarnnam(nam, "can't change option: -%c", **args);
|
||||
}
|
||||
}
|
||||
args++;
|
||||
}
|
||||
doneoptions:
|
||||
|
||||
if (!match) {
|
||||
/* Not globbing the arguments -- arguments are simply option names. */
|
||||
while (*args) {
|
||||
if(!(optno = optlookup(*args++)))
|
||||
zwarnnam(nam, "no such option: %s", args[-1]);
|
||||
else if(dosetopt(optno, !isun, 0, opts))
|
||||
zwarnnam(nam, "can't change option: %s", args[-1]);
|
||||
}
|
||||
} else {
|
||||
/* Globbing option (-m) set. */
|
||||
while (*args) {
|
||||
Patprog pprog;
|
||||
char *s, *t;
|
||||
|
||||
t = s = dupstring(*args);
|
||||
while (*t)
|
||||
if (*t == '_')
|
||||
chuck(t);
|
||||
else {
|
||||
/* See comment in optlookup() */
|
||||
if (*t >= 'A' && *t <= 'Z')
|
||||
*t = (*t - 'A') + 'a';
|
||||
t++;
|
||||
}
|
||||
|
||||
/* Expand the current arg. */
|
||||
tokenize(s);
|
||||
if (!(pprog = patcompile(s, PAT_HEAPDUP, NULL))) {
|
||||
zwarnnam(nam, "bad pattern: %s", *args);
|
||||
continue;
|
||||
}
|
||||
/* Loop over expansions. */
|
||||
scanmatchtable(optiontab, pprog, 0, 0, OPT_ALIAS,
|
||||
setoption, !isun);
|
||||
args++;
|
||||
}
|
||||
}
|
||||
inittyptab();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Identify an option name */
|
||||
|
||||
/**/
|
||||
mod_export int
|
||||
optlookup(char const *name)
|
||||
{
|
||||
char *s, *t;
|
||||
Optname n;
|
||||
|
||||
s = t = dupstring(name);
|
||||
|
||||
/* exorcise underscores, and change to lowercase */
|
||||
while (*t)
|
||||
if (*t == '_')
|
||||
chuck(t);
|
||||
else {
|
||||
/*
|
||||
* Some locales (in particular tr_TR.UTF-8) may
|
||||
* have non-standard mappings of ASCII characters,
|
||||
* so be careful. Option names must be ASCII so
|
||||
* we don't need to be too clever.
|
||||
*/
|
||||
if (*t >= 'A' && *t <= 'Z')
|
||||
*t = (*t - 'A') + 'a';
|
||||
t++;
|
||||
}
|
||||
|
||||
/* look up name in the table */
|
||||
if (s[0] == 'n' && s[1] == 'o' &&
|
||||
(n = (Optname) optiontab->getnode(optiontab, s + 2))) {
|
||||
return -n->optno;
|
||||
} else if ((n = (Optname) optiontab->getnode(optiontab, s)))
|
||||
return n->optno;
|
||||
else
|
||||
return OPT_INVALID;
|
||||
}
|
||||
|
||||
/* Identify an option letter */
|
||||
|
||||
/**/
|
||||
int
|
||||
optlookupc(char c)
|
||||
{
|
||||
if(c < FIRST_OPT || c > LAST_OPT)
|
||||
return 0;
|
||||
|
||||
return optletters[c - FIRST_OPT];
|
||||
}
|
||||
|
||||
/**/
|
||||
static void
|
||||
restrictparam(char *nam)
|
||||
{
|
||||
Param pm = (Param) paramtab->getnode(paramtab, nam);
|
||||
|
||||
if (pm) {
|
||||
pm->node.flags |= PM_SPECIAL | PM_RESTRICTED;
|
||||
return;
|
||||
}
|
||||
createparam(nam, PM_SCALAR | PM_UNSET | PM_SPECIAL | PM_RESTRICTED);
|
||||
}
|
||||
|
||||
/* list of restricted parameters which are not otherwise special */
|
||||
static char *rparams[] = {
|
||||
"SHELL", "HISTFILE", "LD_LIBRARY_PATH", "LD_AOUT_LIBRARY_PATH",
|
||||
"LD_PRELOAD", "LD_AOUT_PRELOAD", NULL
|
||||
};
|
||||
|
||||
/* Set or unset an option, as a result of user request. The option *
|
||||
* number may be negative, indicating that the sense is reversed *
|
||||
* from the usual meaning of the option. */
|
||||
|
||||
/**/
|
||||
mod_export int
|
||||
dosetopt(int optno, int value, int force, char *new_opts)
|
||||
{
|
||||
if(!optno)
|
||||
return -1;
|
||||
if(optno < 0) {
|
||||
optno = -optno;
|
||||
value = !value;
|
||||
}
|
||||
if (optno == RESTRICTED) {
|
||||
if (isset(RESTRICTED))
|
||||
return value ? 0 : -1;
|
||||
if (value) {
|
||||
char **s;
|
||||
|
||||
for (s = rparams; *s; s++)
|
||||
restrictparam(*s);
|
||||
}
|
||||
} else if(!force && optno == EXECOPT && !value && interact) {
|
||||
/* cannot set noexec when interactive */
|
||||
return -1;
|
||||
} else if(!force && (optno == INTERACTIVE || optno == SHINSTDIN ||
|
||||
optno == SINGLECOMMAND)) {
|
||||
if (new_opts[optno] == value)
|
||||
return 0;
|
||||
/* it is not permitted to change the value of these options */
|
||||
return -1;
|
||||
} else if(!force && optno == USEZLE && value) {
|
||||
/* we require a terminal in order to use ZLE */
|
||||
if(!interact || SHTTY == -1 || !shout)
|
||||
return -1;
|
||||
} else if(optno == PRIVILEGED && !value) {
|
||||
/* unsetting PRIVILEGED causes the shell to make itself unprivileged */
|
||||
#ifdef HAVE_SETUID
|
||||
int ignore_err;
|
||||
errno = 0;
|
||||
/*
|
||||
* Set the GID first as if we set the UID to non-privileged it
|
||||
* might be impossible to restore the GID.
|
||||
*
|
||||
* Some OSes (possibly no longer around) have been known to
|
||||
* fail silently the first time, so we attempt the change twice.
|
||||
* If it fails we are guaranteed to pick this up the second
|
||||
* time, so ignore the first time.
|
||||
*
|
||||
* Some versions of gcc make it hard to ignore the results the
|
||||
* first time, hence the following. (These are probably not
|
||||
* systems that require the doubled calls.)
|
||||
*/
|
||||
ignore_err = setgid(getgid());
|
||||
(void)ignore_err;
|
||||
ignore_err = setuid(getuid());
|
||||
(void)ignore_err;
|
||||
if (setgid(getgid())) {
|
||||
zwarn("failed to change group ID: %e", errno);
|
||||
return -1;
|
||||
} else if (setuid(getuid())) {
|
||||
zwarn("failed to change user ID: %e", errno);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
zwarn("setuid not available");
|
||||
return -1;
|
||||
#endif /* not HAVE_SETUID */
|
||||
#ifdef JOB_CONTROL
|
||||
} else if (!force && optno == MONITOR && value) {
|
||||
if (new_opts[optno] == value)
|
||||
return 0;
|
||||
if (SHTTY != -1) {
|
||||
origpgrp = GETPGRP();
|
||||
acquire_pgrp();
|
||||
} else
|
||||
return -1;
|
||||
#else
|
||||
} else if(optno == MONITOR && value) {
|
||||
return -1;
|
||||
#endif /* not JOB_CONTROL */
|
||||
#ifdef GETPWNAM_FAKED
|
||||
} else if(optno == CDABLEVARS && value) {
|
||||
return -1;
|
||||
#endif /* GETPWNAM_FAKED */
|
||||
} else if ((optno == EMACSMODE || optno == VIMODE) && value) {
|
||||
if (sticky && sticky->emulation)
|
||||
return -1;
|
||||
zleentry(ZLE_CMD_SET_KEYMAP, optno);
|
||||
new_opts[(optno == EMACSMODE) ? VIMODE : EMACSMODE] = 0;
|
||||
} else if (optno == SUNKEYBOARDHACK) {
|
||||
/* for backward compatibility */
|
||||
keyboardhackchar = (value ? '`' : '\0');
|
||||
}
|
||||
new_opts[optno] = value;
|
||||
if (optno == BANGHIST || optno == SHINSTDIN)
|
||||
inittyptab();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Function to get value for special parameter `-' */
|
||||
|
||||
/**/
|
||||
char *
|
||||
dashgetfn(UNUSED(Param pm))
|
||||
{
|
||||
static char buf[LAST_OPT - FIRST_OPT + 2];
|
||||
char *val = buf;
|
||||
int i;
|
||||
|
||||
for(i = 0; i <= LAST_OPT - FIRST_OPT; i++) {
|
||||
int optno = optletters[i];
|
||||
if(optno && ((optno > 0) ? isset(optno) : unset(-optno)))
|
||||
*val++ = FIRST_OPT + i;
|
||||
}
|
||||
*val = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* print options for set -o/+o */
|
||||
|
||||
/**/
|
||||
void
|
||||
printoptionstates(int hadplus)
|
||||
{
|
||||
scanhashtable(optiontab, 1, 0, OPT_ALIAS, printoptionnodestate, hadplus);
|
||||
}
|
||||
|
||||
/**/
|
||||
static void
|
||||
printoptionnodestate(HashNode hn, int hadplus)
|
||||
{
|
||||
Optname on = (Optname) hn;
|
||||
int optno = on->optno;
|
||||
|
||||
if (hadplus) {
|
||||
printf("set %co %s%s\n",
|
||||
defset(on, emulation) != isset(optno) ? '-' : '+',
|
||||
defset(on, emulation) ? "no" : "",
|
||||
on->node.nam);
|
||||
} else {
|
||||
if (defset(on, emulation))
|
||||
printf("no%-19s %s\n", on->node.nam, isset(optno) ? "off" : "on");
|
||||
else
|
||||
printf("%-21s %s\n", on->node.nam, isset(optno) ? "on" : "off");
|
||||
}
|
||||
}
|
||||
|
||||
/* Print option list for --help */
|
||||
|
||||
/**/
|
||||
void
|
||||
printoptionlist(void)
|
||||
{
|
||||
short *lp;
|
||||
char c;
|
||||
|
||||
printf("\nNamed options:\n");
|
||||
scanhashtable(optiontab, 1, 0, OPT_ALIAS, printoptionlist_printoption, 0);
|
||||
printf("\nOption aliases:\n");
|
||||
scanhashtable(optiontab, 1, OPT_ALIAS, 0, printoptionlist_printoption, 0);
|
||||
printf("\nOption letters:\n");
|
||||
for(lp = optletters, c = FIRST_OPT; c <= LAST_OPT; lp++, c++) {
|
||||
if(!*lp)
|
||||
continue;
|
||||
printf(" -%c ", c);
|
||||
printoptionlist_printequiv(*lp);
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
static void
|
||||
printoptionlist_printoption(HashNode hn, UNUSED(int ignored))
|
||||
{
|
||||
Optname on = (Optname) hn;
|
||||
|
||||
if(on->node.flags & OPT_ALIAS) {
|
||||
printf(" --%-19s ", on->node.nam);
|
||||
printoptionlist_printequiv(on->optno);
|
||||
} else
|
||||
printf(" --%s\n", on->node.nam);
|
||||
}
|
||||
|
||||
/**/
|
||||
static void
|
||||
printoptionlist_printequiv(int optno)
|
||||
{
|
||||
int isneg = optno < 0;
|
||||
|
||||
optno *= (isneg ? -1 : 1);
|
||||
printf(" equivalent to --%s%s\n", isneg ? "no-" : "", optns[optno-1].node.nam);
|
||||
}
|
||||
|
||||
/**/
|
||||
static char *print_emulate_opts;
|
||||
|
||||
/**/
|
||||
static void
|
||||
print_emulate_option(HashNode hn, int fully)
|
||||
{
|
||||
Optname on = (Optname) hn;
|
||||
|
||||
if (!(on->node.flags & OPT_ALIAS) &&
|
||||
((fully && !(on->node.flags & OPT_SPECIAL)) ||
|
||||
(on->node.flags & OPT_EMULATE)))
|
||||
{
|
||||
if (!print_emulate_opts[on->optno])
|
||||
fputs("no", stdout);
|
||||
puts(on->node.nam);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* List the settings of options associated with an emulation
|
||||
*/
|
||||
|
||||
/**/
|
||||
void list_emulate_options(char *cmdopts, int fully)
|
||||
{
|
||||
print_emulate_opts = cmdopts;
|
||||
scanhashtable(optiontab, 1, 0, 0, print_emulate_option, fully);
|
||||
}
|
5884
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/params.c
vendored
Normal file
5884
.config/zsh/config/omz/plugins/fzf-tab/modules/Src/params.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user