diff options
Diffstat (limited to 'plugins')
27 files changed, 314 insertions, 1724 deletions
diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index f40b0e931..3117c6da4 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -10,6 +10,7 @@ autojump_paths=( /usr/local/share/autojump/autojump.zsh # FreeBSD installation /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default) + /opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs) ) for file in $autojump_paths; do diff --git a/plugins/cargo/.gitignore b/plugins/cargo/.gitignore new file mode 100644 index 000000000..42d7ecdd6 --- /dev/null +++ b/plugins/cargo/.gitignore @@ -0,0 +1 @@ +_cargo diff --git a/plugins/cargo/_cargo b/plugins/cargo/_cargo deleted file mode 100644 index ebff99310..000000000 --- a/plugins/cargo/_cargo +++ /dev/null @@ -1,407 +0,0 @@ -#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' - '(--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' - 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) - _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 - ;; - - git-checkout) - _arguments -s -S $common \ - '--reference=:reference' \ - '--url=:url:_urls' - ;; - - 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)' \ - '--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' \ - '--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 - ;; - - 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' \ - '--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]' \ - '(--lib --doc --bin --example --bench)--test=[test name]' \ - '(--lib --doc --bin --example --test)--bench=[benchmark name]' \ - '*: :_default' - ;; - - 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 -} - - -#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() { - # strip json from the path - local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"} - 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 diff --git a/plugins/cargo/cargo.plugin.zsh b/plugins/cargo/cargo.plugin.zsh new file mode 100644 index 000000000..92eae5359 --- /dev/null +++ b/plugins/cargo/cargo.plugin.zsh @@ -0,0 +1,11 @@ +# COMPLETION FUNCTION +if (( $+commands[rustup] && $+commands[cargo] )); then + if [[ ! -f $ZSH_CACHE_DIR/cargo_version ]] \ + || [[ "$(cargo --version)" != "$(< "$ZSH_CACHE_DIR/cargo_version")" ]] \ + || [[ ! -f $ZSH/plugins/cargo/_cargo ]]; then + rustup completions zsh cargo > $ZSH/plugins/cargo/_cargo + cargo --version > $ZSH_CACHE_DIR/cargo_version + fi + autoload -Uz _cargo + _comps[cargo]=_cargo +fi diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index f7fedb5f2..32f0525aa 100644 --- a/plugins/chruby/chruby.plugin.zsh +++ b/plugins/chruby/chruby.plugin.zsh @@ -37,7 +37,7 @@ _homebrew-installed() { } _chruby-from-homebrew-installed() { - [ -r _brew_prefix ] &> /dev/null + [ -r $_brew_prefix ] &> /dev/null } _ruby-build_installed() { diff --git a/plugins/colemak/.gitignore b/plugins/colemak/.gitignore new file mode 100644 index 000000000..8241f5ed6 --- /dev/null +++ b/plugins/colemak/.gitignore @@ -0,0 +1 @@ +.less diff --git a/plugins/colemak/colemak.plugin.zsh b/plugins/colemak/colemak.plugin.zsh index cb7cc5068..8d3393c44 100644 --- a/plugins/colemak/colemak.plugin.zsh +++ b/plugins/colemak/colemak.plugin.zsh @@ -19,4 +19,15 @@ bindkey -a 'N' vi-join bindkey -a 'j' vi-forward-word-end bindkey -a 'J' vi-forward-blank-word-end -lesskey $ZSH/plugins/colemak/colemak-less +# New less versions will read this file directly +export LESSKEYIN="${0:h:A}/colemak-less" + +# Only run lesskey if less version is older than v582 +less_ver=$(less --version | awk '{print $2;exit}') +autoload -Uz is-at-least +if ! is-at-least 582 $less_ver; then + # Old less versions will read this transformed file + export LESSKEY="${0:h:A}/.less" + lesskey -o "$LESSKEY" "$LESSKEYIN" 2>/dev/null +fi +unset less_ver diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh index 87a658d93..e67f920f0 100644 --- a/plugins/copybuffer/copybuffer.plugin.zsh +++ b/plugins/copybuffer/copybuffer.plugin.zsh @@ -11,4 +11,6 @@ copybuffer () { zle -N copybuffer -bindkey "^O" copybuffer +bindkey -M emacs "^O" copybuffer +bindkey -M viins "^O" copybuffer +bindkey -M vicmd "^O" copybuffer diff --git a/plugins/cp/README.md b/plugins/cp/README.md index e8a9b6ccc..23734243c 100644 --- a/plugins/cp/README.md +++ b/plugins/cp/README.md @@ -25,7 +25,7 @@ The enabled options for rsync are: * `-hhh`: outputs numbers in human-readable format, in units of 1024 (K, M, G, T). -* `--backup-dir=/tmp/rsync`: move backup copies to "/tmp/rsync". +* `--backup-dir="/tmp/rsync-$USERNAME"`: move backup copies to "/tmp/rsync-$USERNAME". * `-e /dev/null`: only work on local files (disable remote shells). diff --git a/plugins/cp/cp.plugin.zsh b/plugins/cp/cp.plugin.zsh index fe6ea87a8..a56259106 100644 --- a/plugins/cp/cp.plugin.zsh +++ b/plugins/cp/cp.plugin.zsh @@ -1,4 +1,4 @@ cpv() { - rsync -pogbr -hhh --backup-dir=/tmp/rsync -e /dev/null --progress "$@" + rsync -pogbr -hhh --backup-dir="/tmp/rsync-${USERNAME}" -e /dev/null --progress "$@" } compdef _files cpv diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 4517e21a8..437e477b9 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -29,14 +29,10 @@ alias unheap='frontend unheap' alias vuejs='frontend vuejs' function _frontend_fallback() { - local url - if [[ "$FRONTEND_SEARCH_FALLBACK" == duckduckgo ]]; then - url="https://duckduckgo.com/?sites=$1&q=" - else - url="https://google.com/search?as_sitesearch=$1&as_q=" - fi - - echo "$url" + case "$FRONTEND_SEARCH_FALLBACK" in + duckduckgo) echo "https://duckduckgo.com/?sites=$1&q=" ;; + *) echo "https://google.com/search?as_sitesearch=$1&as_q=" ;; + esac } function frontend() { @@ -51,7 +47,7 @@ function frontend() { bootsnipp 'https://bootsnipp.com/search?q=' bundlephobia 'https://bundlephobia.com/result?p=' caniuse 'https://caniuse.com/#search=' - codepen 'https://codepen.io/search?q=' + codepen 'https://codepen.io/search/pens?q=' compassdoc 'http://compass-style.org/search?q=' cssflow 'http://www.cssflow.com/search?q=' dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:' diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh index c7aebe697..7368eb3a6 100644 --- a/plugins/gcloud/gcloud.plugin.zsh +++ b/plugins/gcloud/gcloud.plugin.zsh @@ -7,6 +7,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then search_locations=( "$HOME/google-cloud-sdk" "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" + "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" "/usr/share/google-cloud-sdk" "/snap/google-cloud-sdk/current" "/usr/lib64/google-cloud-sdk/" diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh index 0da84f2f5..efe8cbe66 100644 --- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh +++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh @@ -11,8 +11,9 @@ function git-fetch-all { return 0 fi - # Do nothing if auto-fetch disabled - if [[ -z "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]]; then + # Do nothing if auto-fetch is disabled or don't have permissions + if [[ ! -w "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]] || + [[ -f "$gitdir/FETCH_LOG" && ! -w "$gitdir/FETCH_LOG" ]]; then return 0 fi @@ -24,8 +25,9 @@ function git-fetch-all { fi # Fetch all remotes (avoid ssh passphrase prompt) + date -R &>! "$gitdir/FETCH_LOG" GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \ - command git fetch --all 2>/dev/null &>! "$gitdir/FETCH_LOG" + command git fetch --all 2>/dev/null &>> "$gitdir/FETCH_LOG" ) &| } diff --git a/plugins/git/README.md b/plugins/git/README.md index 522257d2d..e53d93b0b 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -23,7 +23,7 @@ plugins=(... git) | gb | git branch | | gba | git branch -a | | gbd | git branch -d | -| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*($(git_main_branch)\|$(git_develop_branch))\s*$)" \| command xargs -n 1 git branch -d | +| gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*($(git_main_branch)\|$(git_develop_branch))\s*$)" \| xargs git branch -d 2>/dev/null | | gbD | git branch -D | | gbl | git blame -b -w | | gbnm | git branch --no-merged | @@ -66,6 +66,7 @@ plugins=(... git) | gds | git diff --staged | | gdt | git diff-tree --no-commit-id --name-only -r | | gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)*.lock" | +| gdu | git diff @{u} | | gdv | git diff -w $@ \| view - | | gdw | git diff --word-diff | | gf | git fetch | @@ -98,18 +99,18 @@ plugins=(... git) | glgga | git log --graph --decorate --all | | glgm | git log --graph --max-count=10 | | glo | git log --oneline --decorate | -| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' | -| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat | +| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' | +| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat | | glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | | glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | -| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all | +| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all | | glog | git log --oneline --decorate --graph | | gloga | git log --oneline --decorate --graph --all | | glp | git log --pretty=\<format\> | | gm | git merge | | gmom | git merge origin/$(git_main_branch) | -| gmt | git mergetool --no-prompt | -| gmtvim | git mergetool --no-prompt --tool=vimdiff | +| gmtl | git mergetool --no-prompt | +| gmtlvim | git mergetool --no-prompt --tool=vimdiff | | gmum | git merge upstream/$(git_main_branch) | | gma | git merge --abort | | gp | git push | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 3cd558692..76e0faed3 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -32,10 +32,10 @@ function work_in_progress() { # Check if main exists and use instead of master function git_main_branch() { command git rev-parse --git-dir &>/dev/null || return - local branch - for branch in main trunk; do - if command git show-ref -q --verify refs/heads/$branch; then - echo $branch + local ref + for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk}; do + if command git show-ref -q --verify $ref; then + echo ${ref:t} return fi done @@ -73,7 +73,7 @@ alias gapt='git apply --3way' alias gb='git branch' alias gba='git branch -a' alias gbd='git branch -d' -alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs -n 1 git branch -d' +alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch -d 2>/dev/null' alias gbD='git branch -D' alias gbl='git blame -b -w' alias gbnm='git branch --no-merged' @@ -119,6 +119,7 @@ alias gdcw='git diff --cached --word-diff' alias gdct='git describe --tags $(git rev-list --tags --max-count=1)' alias gds='git diff --staged' alias gdt='git diff-tree --no-commit-id --name-only -r' +alias gdu='git diff @{u}' alias gdw='git diff --word-diff' function gdnolock() { @@ -210,19 +211,19 @@ alias glgg='git log --graph' alias glgga='git log --graph --decorate --all' alias glgm='git log --graph --max-count=10' alias glo='git log --oneline --decorate' -alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'" -alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat" +alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'" +alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat" alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'" alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short" -alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all" +alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all" alias glog='git log --oneline --decorate --graph' alias gloga='git log --oneline --decorate --graph --all' alias glp="_git_log_prettily" alias gm='git merge' alias gmom='git merge origin/$(git_main_branch)' -alias gmt='git mergetool --no-prompt' -alias gmtvim='git mergetool --no-prompt --tool=vimdiff' +alias gmtl='git mergetool --no-prompt' +alias gmtlvim='git mergetool --no-prompt --tool=vimdiff' alias gmum='git merge upstream/$(git_main_branch)' alias gma='git merge --abort' diff --git a/plugins/kubectx/kubectx.plugin.zsh b/plugins/kubectx/kubectx.plugin.zsh index 56b7217f1..abbdc254b 100644 --- a/plugins/kubectx/kubectx.plugin.zsh +++ b/plugins/kubectx/kubectx.plugin.zsh @@ -3,12 +3,7 @@ typeset -A kubectx_mapping function kubectx_prompt_info() { if [ $commands[kubectl] ]; then local current_ctx=`kubectl config current-context` - - #if associative array declared - if [[ -n $kubectx_mapping ]]; then - echo "${kubectx_mapping[$current_ctx]}" - else - echo $current_ctx - fi + # use value in associative array if it exists, otherwise fall back to the context name + echo "${kubectx_mapping[$current_ctx]:-$current_ctx}" fi } diff --git a/plugins/pyenv/README.md b/plugins/pyenv/README.md index d063b55b9..b9ee937b7 100644 --- a/plugins/pyenv/README.md +++ b/plugins/pyenv/README.md @@ -1,4 +1,4 @@ -# pyenv +# pyenv This plugin looks for [pyenv](https://github.com/pyenv/pyenv), a Simple Python version management system, and loads it if it's found. It also loads pyenv-virtualenv, a pyenv @@ -10,6 +10,14 @@ To use it, add `pyenv` to the plugins array in your zshrc file: plugins=(... pyenv) ``` +## Settings + +- `ZSH_PYENV_QUIET`: if set to `true`, the plugin will not print any messages if it + finds that `pyenv` is not properly configured. + +- `ZSH_PYENV_VIRTUALENV`: if set to `false`, the plugin will not load pyenv-virtualenv + when it finds it. + ## Functions - `pyenv_prompt_info`: displays the Python version in use by pyenv; or the global Python diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 813f64b42..d91b5daa7 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -1,3 +1,24 @@ +pyenv_config_warning() { + [[ "$ZSH_PYENV_QUIET" != true ]] || return 0 + + local reason="$1" + local pyenv_root="${PYENV_ROOT/#$HOME/\$HOME}" + cat >&2 <<EOF +Found pyenv, but it is badly configured ($reason). pyenv might not +work correctly for non-interactive shells (for example, when run from a script). +${(%):-"%B%F{yellow}"} +To fix this message, add these lines to the '.profile' and '.zprofile' files +in your home directory: +${(%):-"%f"} +export PYENV_ROOT="$pyenv_root" +export PATH="\$PYENV_ROOT/bin:\$PATH" +eval "\$(pyenv init --path)" +${(%):-"%F{yellow}"} +You'll need to restart your user session for the changes to take effect.${(%):-%b%f} +For more information go to https://github.com/pyenv/pyenv/#installation. +EOF +} + # This plugin loads pyenv into the current shell and provides prompt info via # the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available. @@ -30,31 +51,34 @@ if [[ $FOUND_PYENV -ne 1 ]]; then # If we found pyenv, load it but show a caveat about non-interactive shells if [[ $FOUND_PYENV -eq 1 ]]; then - cat <<EOF -Found pyenv, but it is badly configured. pyenv might not work for -non-interactive shells (for example, when run from a script). -${bold_color} -To fix this message, add these lines to the '.profile' and '.zprofile' files -in your home directory: - -export PYENV_ROOT="${dir/#$HOME/\$HOME}" -export PATH="\$PYENV_ROOT/bin:\$PATH" -eval "\$(pyenv init --path)" -${reset_color} -For more info go to https://github.com/pyenv/pyenv/#installation. -EOF - # Configuring in .zshrc only makes pyenv available for interactive shells - export PYENV_ROOT=$dir + export PYENV_ROOT="$dir" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)" + + # Show warning due to bad pyenv configuration + pyenv_config_warning 'pyenv command not found in $PATH' fi fi if [[ $FOUND_PYENV -eq 1 ]]; then + if [[ -z "$PYENV_ROOT" ]]; then + # This is only for backwards compatibility with users that previously relied + # on this plugin exporting it. pyenv itself does not require it to be exported + export PYENV_ROOT="$(pyenv root)" + fi + + # Add pyenv shims to $PATH if not already added + if [[ -z "${path[(Re)$(pyenv root)/shims]}" ]]; then + eval "$(pyenv init --path)" + pyenv_config_warning 'missing pyenv shims in $PATH' + fi + + # Load pyenv eval "$(pyenv init - --no-rehash zsh)" - if (( ${+commands[pyenv-virtualenv-init]} )); then + # If pyenv-virtualenv exists, load it + if [[ -d "$(pyenv root)/plugins/pyenv-virtualenv" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then eval "$(pyenv virtualenv-init - zsh)" fi @@ -69,3 +93,4 @@ else fi unset FOUND_PYENV pyenvdirs dir +unfunction pyenv_config_warning diff --git a/plugins/rustup/.gitignore b/plugins/rustup/.gitignore new file mode 100644 index 000000000..ad38ae3bf --- /dev/null +++ b/plugins/rustup/.gitignore @@ -0,0 +1 @@ +_rustup diff --git a/plugins/rustup/_rustup b/plugins/rustup/_rustup deleted file mode 100644 index dab33533a..000000000 --- a/plugins/rustup/_rustup +++ /dev/null @@ -1,1143 +0,0 @@ -#compdef rustup - -autoload -U is-at-least - -_rustup() { - 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[@]}" \ -'-v[Enable verbose output]' \ -'--verbose[Enable verbose output]' \ -'(-v --verbose)-q[Disable progress output]' \ -'(-v --verbose)--quiet[Disable progress output]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -'::+toolchain -- release channel (e.g. +stable) or custom toolchain to set override:_files' \ -":: :_rustup_commands" \ -"*::: :->rustup" \ -&& ret=0 - case $state in - (rustup) - words=($line[2] "${words[@]}") - (( CURRENT += 1 )) - curcontext="${curcontext%:*:*}:rustup-command-$line[2]:" - case $line[2] in - (dump-testament) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(show) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -":: :_rustup__show_commands" \ -"*::: :->show" \ -&& ret=0 -case $state in - (show) - words=($line[1] "${words[@]}") - (( CURRENT += 1 )) - curcontext="${curcontext%:*:*}:rustup-show-command-$line[1]:" - case $line[1] in - (active-toolchain) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(home) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(profile) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(keys) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(help) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; - esac - ;; -esac -;; -(install) -_arguments "${_arguments_options[@]}" \ -'--profile=[]: :(minimal default complete)' \ -'--no-self-update[Don'\''t perform self-update when running the `rustup install` command]' \ -'--force[Force an update, even if some components are missing]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(uninstall) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(update) -_arguments "${_arguments_options[@]}" \ -'--no-self-update[Don'\''t perform self update when running the `rustup update` command]' \ -'--force[Force an update, even if some components are missing]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -'::toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(check) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(default) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -'::toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(toolchain) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -":: :_rustup__toolchain_commands" \ -"*::: :->toolchain" \ -&& ret=0 -case $state in - (toolchain) - words=($line[1] "${words[@]}") - (( CURRENT += 1 )) - curcontext="${curcontext%:*:*}:rustup-toolchain-command-$line[1]:" - case $line[1] in - (list) -_arguments "${_arguments_options[@]}" \ -'-v[Enable verbose output with toolchain information]' \ -'--verbose[Enable verbose output with toolchain information]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(update) -_arguments "${_arguments_options[@]}" \ -'--profile=[]: :(minimal default complete)' \ -'*-c+[Add specific components on installation]' \ -'*--component=[Add specific components on installation]' \ -'*-t+[Add specific targets on installation]' \ -'*--target=[Add specific targets on installation]' \ -'--no-self-update[Don'\''t perform self update when running the`rustup toolchain install` command]' \ -'--force[Force an update, even if some components are missing]' \ -'--allow-downgrade[Allow rustup to downgrade the toolchain to satisfy your component choice]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(add) -_arguments "${_arguments_options[@]}" \ -'--profile=[]: :(minimal default complete)' \ -'*-c+[Add specific components on installation]' \ -'*--component=[Add specific components on installation]' \ -'*-t+[Add specific targets on installation]' \ -'*--target=[Add specific targets on installation]' \ -'--no-self-update[Don'\''t perform self update when running the`rustup toolchain install` command]' \ -'--force[Force an update, even if some components are missing]' \ -'--allow-downgrade[Allow rustup to downgrade the toolchain to satisfy your component choice]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(install) -_arguments "${_arguments_options[@]}" \ -'--profile=[]: :(minimal default complete)' \ -'*-c+[Add specific components on installation]' \ -'*--component=[Add specific components on installation]' \ -'*-t+[Add specific targets on installation]' \ -'*--target=[Add specific targets on installation]' \ -'--no-self-update[Don'\''t perform self update when running the`rustup toolchain install` command]' \ -'--force[Force an update, even if some components are missing]' \ -'--allow-downgrade[Allow rustup to downgrade the toolchain to satisfy your component choice]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(remove) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(uninstall) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(link) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -':path:_files' \ -&& ret=0 -;; -(help) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; - esac - ;; -esac -;; -(target) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -":: :_rustup__target_commands" \ -"*::: :->target" \ -&& ret=0 -case $state in - (target) - words=($line[1] "${words[@]}") - (( CURRENT += 1 )) - curcontext="${curcontext%:*:*}:rustup-target-command-$line[1]:" - case $line[1] in - (list) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'--installed[List only installed targets]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(install) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':target -- List of targets to install; "all" installs all available targets:_files' \ -&& ret=0 -;; -(add) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':target -- List of targets to install; "all" installs all available targets:_files' \ -&& ret=0 -;; -(uninstall) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':target:_files' \ -&& ret=0 -;; -(remove) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':target:_files' \ -&& ret=0 -;; -(help) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; - esac - ;; -esac -;; -(component) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -":: :_rustup__component_commands" \ -"*::: :->component" \ -&& ret=0 -case $state in - (component) - words=($line[1] "${words[@]}") - (( CURRENT += 1 )) - curcontext="${curcontext%:*:*}:rustup-component-command-$line[1]:" - case $line[1] in - (list) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'--installed[List only installed components]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(add) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'--target=[]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':component:_files' \ -&& ret=0 -;; -(remove) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'--target=[]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':component:_files' \ -&& ret=0 -;; -(help) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; - esac - ;; -esac -;; -(override) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -":: :_rustup__override_commands" \ -"*::: :->override" \ -&& ret=0 -case $state in - (override) - words=($line[1] "${words[@]}") - (( CURRENT += 1 )) - curcontext="${curcontext%:*:*}:rustup-override-command-$line[1]:" - case $line[1] in - (list) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(add) -_arguments "${_arguments_options[@]}" \ -'--path=[Path to the directory]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(set) -_arguments "${_arguments_options[@]}" \ -'--path=[Path to the directory]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -&& ret=0 -;; -(remove) -_arguments "${_arguments_options[@]}" \ -'--path=[Path to the directory]' \ -'--nonexistent[Remove override toolchain for all nonexistent directories]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(unset) -_arguments "${_arguments_options[@]}" \ -'--path=[Path to the directory]' \ -'--nonexistent[Remove override toolchain for all nonexistent directories]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(help) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; - esac - ;; -esac -;; -(run) -_arguments "${_arguments_options[@]}" \ -'--install[Install the requested toolchain if needed]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ -':command:_files' \ -&& ret=0 -;; -(which) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':command:_files' \ -&& ret=0 -;; -(docs) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'--path[Only print the path to the documentation]' \ -'--alloc[The Rust core allocation and collections library]' \ -'--book[The Rust Programming Language book]' \ -'--cargo[The Cargo Book]' \ -'--core[The Rust Core Library]' \ -'--edition-guide[The Rust Edition Guide]' \ -'--nomicon[The Dark Arts of Advanced and Unsafe Rust Programming]' \ -'--proc_macro[A support library for macro authors when defining new macros]' \ -'--reference[The Rust Reference]' \ -'--rust-by-example[A collection of runnable examples that illustrate various Rust concepts and standard libraries]' \ -'--rustc[The compiler for the Rust programming language]' \ -'--rustdoc[Generate documentation for Rust projects]' \ -'--std[Standard library API documentation]' \ -'--test[Support code for rustc'\''s built in unit-test and micro-benchmarking framework]' \ -'--unstable-book[The Unstable Book]' \ -'--embedded-book[The Embedded Rust Book]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -'::topic -- Topic such as 'core', 'fn', 'usize', 'eprintln!', 'core::arch', 'alloc::format!', 'std::fs', 'std::fs::read_dir', 'std::io::Bytes', 'std::iter::Sum', 'std::io::error::Result' etc...:_files' \ -&& ret=0 -;; -(doc) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'--path[Only print the path to the documentation]' \ -'--alloc[The Rust core allocation and collections library]' \ -'--book[The Rust Programming Language book]' \ -'--cargo[The Cargo Book]' \ -'--core[The Rust Core Library]' \ -'--edition-guide[The Rust Edition Guide]' \ -'--nomicon[The Dark Arts of Advanced and Unsafe Rust Programming]' \ -'--proc_macro[A support library for macro authors when defining new macros]' \ -'--reference[The Rust Reference]' \ -'--rust-by-example[A collection of runnable examples that illustrate various Rust concepts and standard libraries]' \ -'--rustc[The compiler for the Rust programming language]' \ -'--rustdoc[Generate documentation for Rust projects]' \ -'--std[Standard library API documentation]' \ -'--test[Support code for rustc'\''s built in unit-test and micro-benchmarking framework]' \ -'--unstable-book[The Unstable Book]' \ -'--embedded-book[The Embedded Rust Book]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -'::topic -- Topic such as 'core', 'fn', 'usize', 'eprintln!', 'core::arch', 'alloc::format!', 'std::fs', 'std::fs::read_dir', 'std::io::Bytes', 'std::iter::Sum', 'std::io::error::Result' etc...:_files' \ -&& ret=0 -;; -(man) -_arguments "${_arguments_options[@]}" \ -'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':command:_files' \ -&& ret=0 -;; -(self) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -":: :_rustup__self_commands" \ -"*::: :->self" \ -&& ret=0 -case $state in - (self) - words=($line[1] "${words[@]}") - (( CURRENT += 1 )) - curcontext="${curcontext%:*:*}:rustup-self-command-$line[1]:" - case $line[1] in - (update) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(uninstall) -_arguments "${_arguments_options[@]}" \ -'-y[]' \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(upgrade-data) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; -(help) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; - esac - ;; -esac -;; -(set) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -":: :_rustup__set_commands" \ -"*::: :->set" \ -&& ret=0 -case $state in - (set) - words=($line[1] "${words[@]}") - (( CURRENT += 1 )) - curcontext="${curcontext%:*:*}:rustup-set-command-$line[1]:" - case $line[1] in - (default-host) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':host_triple:_files' \ -&& ret=0 -;; -(profile) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -':profile-name:(minimal default complete)' \ -&& ret=0 -;; -(help) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; - esac - ;; -esac -;; -(completions) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -'::shell:(zsh bash fish powershell elvish)' \ -'::command:(rustup cargo)' \ -&& ret=0 -;; -(help) -_arguments "${_arguments_options[@]}" \ -'-h[Prints help information]' \ -'--help[Prints help information]' \ -'-V[Prints version information]' \ -'--version[Prints version information]' \ -&& ret=0 -;; - esac - ;; -esac -} - -(( $+functions[_rustup_commands] )) || -_rustup_commands() { - local commands; commands=( - "dump-testament:Dump information about the build" \ -"show:Show the active and installed toolchains or profiles" \ -"install:Update Rust toolchains" \ -"uninstall:Uninstall Rust toolchains" \ -"update:Update Rust toolchains and rustup" \ -"check:Check for updates to Rust toolchains" \ -"default:Set the default toolchain" \ -"toolchain:Modify or query the installed toolchains" \ -"target:Modify a toolchain's supported targets" \ -"component:Modify a toolchain's installed components" \ -"override:Modify directory toolchain overrides" \ -"run:Run a command with an environment configured for a given toolchain" \ -"which:Display which binary will be run for a given command" \ -"doc:Open the documentation for the current toolchain" \ -"man:View the man page for a given command" \ -"self:Modify the rustup installation" \ -"set:Alter rustup settings" \ -"completions:Generate tab-completion scripts for your shell" \ -"help:Prints this message or the help of the given subcommand(s)" \ - ) - _describe -t commands 'rustup commands' commands "$@" -} -(( $+functions[_rustup__show__active-toolchain_commands] )) || -_rustup__show__active-toolchain_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup show active-toolchain commands' commands "$@" -} -(( $+functions[_rustup__add_commands] )) || -_rustup__add_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup add commands' commands "$@" -} -(( $+functions[_rustup__component__add_commands] )) || -_rustup__component__add_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup component add commands' commands "$@" -} -(( $+functions[_rustup__override__add_commands] )) || -_rustup__override__add_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup override add commands' commands "$@" -} -(( $+functions[_rustup__target__add_commands] )) || -_rustup__target__add_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup target add commands' commands "$@" -} -(( $+functions[_rustup__toolchain__add_commands] )) || -_rustup__toolchain__add_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup toolchain add commands' commands "$@" -} -(( $+functions[_rustup__check_commands] )) || -_rustup__check_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup check commands' commands "$@" -} -(( $+functions[_rustup__completions_commands] )) || -_rustup__completions_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup completions commands' commands "$@" -} -(( $+functions[_rustup__component_commands] )) || -_rustup__component_commands() { - local commands; commands=( - "list:List installed and available components" \ -"add:Add a component to a Rust toolchain" \ -"remove:Remove a component from a Rust toolchain" \ -"help:Prints this message or the help of the given subcommand(s)" \ - ) - _describe -t commands 'rustup component commands' commands "$@" -} -(( $+functions[_rustup__default_commands] )) || -_rustup__default_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup default commands' commands "$@" -} -(( $+functions[_rustup__set__default-host_commands] )) || -_rustup__set__default-host_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup set default-host commands' commands "$@" -} -(( $+functions[_rustup__doc_commands] )) || -_rustup__doc_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup doc commands' commands "$@" -} -(( $+functions[_docs_commands] )) || -_docs_commands() { - local commands; commands=( - - ) - _describe -t commands 'docs commands' commands "$@" -} -(( $+functions[_rustup__docs_commands] )) || -_rustup__docs_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup docs commands' commands "$@" -} -(( $+functions[_rustup__dump-testament_commands] )) || -_rustup__dump-testament_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup dump-testament commands' commands "$@" -} -(( $+functions[_rustup__component__help_commands] )) || -_rustup__component__help_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup component help commands' commands "$@" -} -(( $+functions[_rustup__help_commands] )) || -_rustup__help_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup help commands' commands "$@" -} -(( $+functions[_rustup__override__help_commands] )) || -_rustup__override__help_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup override help commands' commands "$@" -} -(( $+functions[_rustup__self__help_commands] )) || -_rustup__self__help_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup self help commands' commands "$@" -} -(( $+functions[_rustup__set__help_commands] )) || -_rustup__set__help_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup set help commands' commands "$@" -} -(( $+functions[_rustup__show__help_commands] )) || -_rustup__show__help_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup show help commands' commands "$@" -} -(( $+functions[_rustup__target__help_commands] )) || -_rustup__target__help_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup target help commands' commands "$@" -} -(( $+functions[_rustup__toolchain__help_commands] )) || -_rustup__toolchain__help_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup toolchain help commands' commands "$@" -} -(( $+functions[_rustup__show__home_commands] )) || -_rustup__show__home_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup show home commands' commands "$@" -} -(( $+functions[_rustup__install_commands] )) || -_rustup__install_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup install commands' commands "$@" -} -(( $+functions[_rustup__target__install_commands] )) || -_rustup__target__install_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup target install commands' commands "$@" -} -(( $+functions[_rustup__toolchain__install_commands] )) || -_rustup__toolchain__install_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup toolchain install commands' commands "$@" -} -(( $+functions[_rustup__show__keys_commands] )) || -_rustup__show__keys_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup show keys commands' commands "$@" -} -(( $+functions[_rustup__toolchain__link_commands] )) || -_rustup__toolchain__link_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup toolchain link commands' commands "$@" -} -(( $+functions[_rustup__component__list_commands] )) || -_rustup__component__list_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup component list commands' commands "$@" -} -(( $+functions[_rustup__override__list_commands] )) || -_rustup__override__list_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup override list commands' commands "$@" -} -(( $+functions[_rustup__target__list_commands] )) || -_rustup__target__list_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup target list commands' commands "$@" -} -(( $+functions[_rustup__toolchain__list_commands] )) || -_rustup__toolchain__list_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup toolchain list commands' commands "$@" -} -(( $+functions[_rustup__man_commands] )) || -_rustup__man_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup man commands' commands "$@" -} -(( $+functions[_rustup__override_commands] )) || -_rustup__override_commands() { - local commands; commands=( - "list:List directory toolchain overrides" \ -"set:Set the override toolchain for a directory" \ -"unset:Remove the override toolchain for a directory" \ -"help:Prints this message or the help of the given subcommand(s)" \ - ) - _describe -t commands 'rustup override commands' commands "$@" -} -(( $+functions[_rustup__set__profile_commands] )) || -_rustup__set__profile_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup set profile commands' commands "$@" -} -(( $+functions[_rustup__show__profile_commands] )) || -_rustup__show__profile_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup show profile commands' commands "$@" -} -(( $+functions[_rustup__component__remove_commands] )) || -_rustup__component__remove_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup component remove commands' commands "$@" -} -(( $+functions[_rustup__override__remove_commands] )) || -_rustup__override__remove_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup override remove commands' commands "$@" -} -(( $+functions[_rustup__remove_commands] )) || -_rustup__remove_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup remove commands' commands "$@" -} -(( $+functions[_rustup__target__remove_commands] )) || -_rustup__target__remove_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup target remove commands' commands "$@" -} -(( $+functions[_rustup__toolchain__remove_commands] )) || -_rustup__toolchain__remove_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup toolchain remove commands' commands "$@" -} -(( $+functions[_rustup__run_commands] )) || -_rustup__run_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup run commands' commands "$@" -} -(( $+functions[_rustup__self_commands] )) || -_rustup__self_commands() { - local commands; commands=( - "update:Download and install updates to rustup" \ -"uninstall:Uninstall rustup." \ -"upgrade-data:Upgrade the internal data format." \ -"help:Prints this message or the help of the given subcommand(s)" \ - ) - _describe -t commands 'rustup self commands' commands "$@" -} -(( $+functions[_rustup__override__set_commands] )) || -_rustup__override__set_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup override set commands' commands "$@" -} -(( $+functions[_rustup__set_commands] )) || -_rustup__set_commands() { - local commands; commands=( - "default-host:The triple used to identify toolchains when not specified" \ -"profile:The default components installed" \ -"help:Prints this message or the help of the given subcommand(s)" \ - ) - _describe -t commands 'rustup set commands' commands "$@" -} -(( $+functions[_rustup__show_commands] )) || -_rustup__show_commands() { - local commands; commands=( - "active-toolchain:Show the active toolchain" \ -"home:Display the computed value of RUSTUP_HOME" \ -"profile:Show the current profile" \ -"keys:Display the known PGP keys" \ -"help:Prints this message or the help of the given subcommand(s)" \ - ) - _describe -t commands 'rustup show commands' commands "$@" -} -(( $+functions[_rustup__target_commands] )) || -_rustup__target_commands() { - local commands; commands=( - "list:List installed and available targets" \ -"add:Add a target to a Rust toolchain" \ -"remove:Remove a target from a Rust toolchain" \ -"help:Prints this message or the help of the given subcommand(s)" \ - ) - _describe -t commands 'rustup target commands' commands "$@" -} -(( $+functions[_rustup__toolchain_commands] )) || -_rustup__toolchain_commands() { - local commands; commands=( - "list:List installed toolchains" \ -"install:Install or update a given toolchain" \ -"uninstall:Uninstall a toolchain" \ -"link:Create a custom toolchain by symlinking to a directory" \ -"help:Prints this message or the help of the given subcommand(s)" \ - ) - _describe -t commands 'rustup toolchain commands' commands "$@" -} -(( $+functions[_rustup__self__uninstall_commands] )) || -_rustup__self__uninstall_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup self uninstall commands' commands "$@" -} -(( $+functions[_rustup__target__uninstall_commands] )) || -_rustup__target__uninstall_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup target uninstall commands' commands "$@" -} -(( $+functions[_rustup__toolchain__uninstall_commands] )) || -_rustup__toolchain__uninstall_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup toolchain uninstall commands' commands "$@" -} -(( $+functions[_rustup__uninstall_commands] )) || -_rustup__uninstall_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup uninstall commands' commands "$@" -} -(( $+functions[_rustup__override__unset_commands] )) || -_rustup__override__unset_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup override unset commands' commands "$@" -} -(( $+functions[_rustup__self__update_commands] )) || -_rustup__self__update_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup self update commands' commands "$@" -} -(( $+functions[_rustup__toolchain__update_commands] )) || -_rustup__toolchain__update_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup toolchain update commands' commands "$@" -} -(( $+functions[_rustup__update_commands] )) || -_rustup__update_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup update commands' commands "$@" -} -(( $+functions[_rustup__self__upgrade-data_commands] )) || -_rustup__self__upgrade-data_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup self upgrade-data commands' commands "$@" -} -(( $+functions[_rustup__which_commands] )) || -_rustup__which_commands() { - local commands; commands=( - - ) - _describe -t commands 'rustup which commands' commands "$@" -} - -_rustup "$@"
\ No newline at end of file diff --git a/plugins/rustup/rustup.plugin.zsh b/plugins/rustup/rustup.plugin.zsh new file mode 100644 index 000000000..c7a9b3060 --- /dev/null +++ b/plugins/rustup/rustup.plugin.zsh @@ -0,0 +1,12 @@ +# COMPLETION FUNCTION +if (( $+commands[rustup] )); then + if [[ ! -f $ZSH_CACHE_DIR/rustup_version ]] \ + || [[ "$(rustup --version 2> /dev/null)" \ + != "$(< "$ZSH_CACHE_DIR/rustup_version")" ]] \ + || [[ ! -f $ZSH/plugins/rustup/_rustup ]]; then + rustup completions zsh > $ZSH/plugins/rustup/_rustup + rustup --version 2> /dev/null > $ZSH_CACHE_DIR/rustup_version + fi + autoload -Uz _rustup + _comps[rustup]=_rustup +fi diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md index 8765a9c7e..d1a504b1e 100644 --- a/plugins/ssh-agent/README.md +++ b/plugins/ssh-agent/README.md @@ -27,6 +27,15 @@ To **load multiple identities** use the `identities` style, For example: zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github ``` +**NOTE:** the identities may be an absolute path if they are somewhere other than +`~/.ssh`. For example: + +```zsh +zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/id_rsa ~/.config/ssh/id_rsa2 ~/.config/ssh/id_github +# which can be simplified to +zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/{id_rsa,id_rsa2,id_github} +``` + ---- To **set the maximum lifetime of the identities**, use the `lifetime` style. @@ -55,6 +64,15 @@ ssh-add -K -c -a /run/user/1000/ssh-auth <identities> For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`. +---- + +To set an **external helper** to ask for the passwords and possibly store +them in the system keychain use the `helper` style. For example: + +```zsh +zstyle :omz:plugins:ssh-agent helper ksshaskpass +``` + ## Credits Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index d45406f63..2d7d8a2a0 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -1,84 +1,102 @@ -typeset _agent_forwarding _ssh_env_cache +# Get the filename to store/lookup the environment from +ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST" function _start_agent() { - local lifetime - zstyle -s :omz:plugins:ssh-agent lifetime lifetime - - # start ssh-agent and setup environment - echo Starting ssh-agent... - ssh-agent -s ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! $_ssh_env_cache - chmod 600 $_ssh_env_cache - . $_ssh_env_cache > /dev/null + # Check if ssh-agent is already running + if [[ -f "$ssh_env_cache" ]]; then + . "$ssh_env_cache" > /dev/null + + { + [[ "$USERNAME" = root ]] && command ps ax || command ps x + } | command grep ssh-agent | command grep -q $SSH_AGENT_PID && return 0 + fi + + # Set a maximum lifetime for identities added to ssh-agent + local lifetime + zstyle -s :omz:plugins:ssh-agent lifetime lifetime + + # start ssh-agent and setup environment + echo Starting ssh-agent... + ssh-agent -s ${lifetime:+-t} ${lifetime} | sed '/^echo/d' >! "$ssh_env_cache" + chmod 600 "$ssh_env_cache" + . "$ssh_env_cache" > /dev/null } function _add_identities() { - local id line sig lines - local -a identities loaded_sigs loaded_ids not_loaded - zstyle -a :omz:plugins:ssh-agent identities identities - - # check for .ssh folder presence - if [[ ! -d $HOME/.ssh ]]; then - return - fi - - # add default keys if no identities were set up via zstyle - # this is to mimic the call to ssh-add with no identities - if [[ ${#identities} -eq 0 ]]; then - # key list found on `ssh-add` man page's DESCRIPTION section - for id in id_rsa id_dsa id_ecdsa id_ed25519 identity; do - # check if file exists - [[ -f "$HOME/.ssh/$id" ]] && identities+=$id - done - fi - - # get list of loaded identities' signatures and filenames - if lines=$(ssh-add -l); then - for line in ${(f)lines}; do - loaded_sigs+=${${(z)line}[2]} - loaded_ids+=${${(z)line}[3]} - done - fi - - # add identities if not already loaded - for id in $identities; do - # check for filename match, otherwise try for signature match - if [[ ${loaded_ids[(I)$HOME/.ssh/$id]} -le 0 ]]; then - sig="$(ssh-keygen -lf "$HOME/.ssh/$id" | awk '{print $2}')" - [[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+="$HOME/.ssh/$id" - fi - done - - local args - zstyle -a :omz:plugins:ssh-agent ssh-add-args args - [[ -n "$not_loaded" ]] && ssh-add "${args[@]}" ${^not_loaded} -} + local id file line sig lines + local -a identities loaded_sigs loaded_ids not_loaded + zstyle -a :omz:plugins:ssh-agent identities identities -# Get the filename to store/lookup the environment from -_ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST" + # check for .ssh folder presence + if [[ ! -d "$HOME/.ssh" ]]; then + return + fi + + # add default keys if no identities were set up via zstyle + # this is to mimic the call to ssh-add with no identities + if [[ ${#identities} -eq 0 ]]; then + # key list found on `ssh-add` man page's DESCRIPTION section + for id in id_rsa id_dsa id_ecdsa id_ed25519 identity; do + # check if file exists + [[ -f "$HOME/.ssh/$id" ]] && identities+=($id) + done + fi + + # get list of loaded identities' signatures and filenames + if lines=$(ssh-add -l); then + for line in ${(f)lines}; do + loaded_sigs+=${${(z)line}[2]} + loaded_ids+=${${(z)line}[3]} + done + fi + + # add identities if not already loaded + for id in $identities; do + # if id is an absolute path, make file equal to id + [[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id" + # check for filename match, otherwise try for signature match + if [[ ${loaded_ids[(I)$file]} -le 0 ]]; then + sig="$(ssh-keygen -lf "$file" | awk '{print $2}')" + [[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file") + fi + done + + # abort if no identities need to be loaded + if [[ ${#not_loaded} -eq 0 ]]; then + return + fi + + # pass extra arguments to ssh-add + local args + zstyle -a :omz:plugins:ssh-agent ssh-add-args args + + # use user specified helper to ask for password (ksshaskpass, etc) + local helper + zstyle -s :omz:plugins:ssh-agent helper helper + + if [[ -n "$helper" ]]; then + if [[ -z "${commands[$helper]}" ]]; then + echo "ssh-agent: the helper '$helper' has not been found." + else + SSH_ASKPASS="$helper" ssh-add "${args[@]}" ${^not_loaded} < /dev/null + return $? + fi + fi + + ssh-add "${args[@]}" ${^not_loaded} +} # test if agent-forwarding is enabled -zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding - -if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then - # Add a nifty symlink for screen/tmux if agent forwarding - [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen -elif [[ -f "$_ssh_env_cache" ]]; then - # Source SSH settings, if applicable - . $_ssh_env_cache > /dev/null - if [[ $USERNAME == "root" ]]; then - FILTER="ax" - else - FILTER="x" - fi - ps $FILTER | grep ssh-agent | grep -q $SSH_AGENT_PID || { - _start_agent - } +zstyle -b :omz:plugins:ssh-agent agent-forwarding agent_forwarding + +# Add a nifty symlink for screen/tmux if agent forwarding +if [[ $agent_forwarding = "yes" && -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then + ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen else - _start_agent + _start_agent fi _add_identities -# tidy up after ourselves -unset _agent_forwarding _ssh_env_cache +unset agent_forwarding ssh_env_cache unfunction _start_agent _add_identities diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index f2445a762..e02f88a87 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -15,48 +15,76 @@ # ------------------------------------------------------------------------------ __sudo-replace-buffer() { - local old=$1 new=$2 space=${2:+ } - if [[ ${#LBUFFER} -le ${#old} ]]; then - RBUFFER="${space}${BUFFER#$old }" - LBUFFER="${new}" - else - LBUFFER="${new}${space}${LBUFFER#$old }" - fi + local old=$1 new=$2 space=${2:+ } + if [[ ${#LBUFFER} -le ${#old} ]]; then + RBUFFER="${space}${BUFFER#$old }" + LBUFFER="${new}" + else + LBUFFER="${new}${space}${LBUFFER#$old }" + fi } sudo-command-line() { - [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" + # If line is empty, get the last run command from history + [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" - # Save beginning space - local WHITESPACE="" - if [[ ${LBUFFER:0:1} = " " ]]; then - WHITESPACE=" " - LBUFFER="${LBUFFER:1}" - fi + # Save beginning space + local WHITESPACE="" + if [[ ${LBUFFER:0:1} = " " ]]; then + WHITESPACE=" " + LBUFFER="${LBUFFER:1}" + fi - # Get the first part of the typed command and check if it's an alias to $EDITOR - # If so, locally change $EDITOR to the alias so that it matches below - if [[ -n "$EDITOR" ]]; then - local cmd="${${(Az)BUFFER}[1]}" - if [[ "${aliases[$cmd]} " = (\$EDITOR|$EDITOR)\ * ]]; then - local EDITOR="$cmd" - fi - fi + # If $EDITOR is not set, just toggle the sudo prefix on and off + if [[ -z "$EDITOR" ]]; then + case "$BUFFER" in + sudoedit\ *) __sudo-replace-buffer "sudoedit" "" ;; + sudo\ *) __sudo-replace-buffer "sudo" "" ;; + *) LBUFFER="sudo $LBUFFER" ;; + esac + else + # Check if the typed command is really an alias to $EDITOR - if [[ -n $EDITOR && $BUFFER = $EDITOR\ * ]]; then - __sudo-replace-buffer "$EDITOR" "sudoedit" - elif [[ -n $EDITOR && $BUFFER = \$EDITOR\ * ]]; then - __sudo-replace-buffer "\$EDITOR" "sudoedit" - elif [[ $BUFFER = sudoedit\ * ]]; then - __sudo-replace-buffer "sudoedit" "$EDITOR" - elif [[ $BUFFER = sudo\ * ]]; then - __sudo-replace-buffer "sudo" "" - else - LBUFFER="sudo $LBUFFER" + # Get the first part of the typed command + local cmd="${${(Az)BUFFER}[1]}" + # Get the first part of the alias of the same name as $cmd, or $cmd if no alias matches + local realcmd="${${(Az)aliases[$cmd]}[1]:-$cmd}" + # Get the first part of the $EDITOR command ($EDITOR may have arguments after it) + local editorcmd="${${(Az)EDITOR}[1]}" + + # Note: ${var:c} makes a $PATH search and expands $var to the full path + # The if condition is met when: + # - $realcmd is '$EDITOR' + # - $realcmd is "cmd" and $EDITOR is "cmd" + # - $realcmd is "cmd" and $EDITOR is "cmd --with --arguments" + # - $realcmd is "/path/to/cmd" and $EDITOR is "cmd" + # - $realcmd is "/path/to/cmd" and $EDITOR is "/path/to/cmd" + # or + # - $realcmd is "cmd" and $EDITOR is "cmd" + # - $realcmd is "cmd" and $EDITOR is "/path/to/cmd" + # or + # - $realcmd is "cmd" and $EDITOR is /alternative/path/to/cmd that appears in $PATH + if [[ "$realcmd" = (\$EDITOR|$editorcmd|${editorcmd:c}) \ + || "${realcmd:c}" = ($editorcmd|${editorcmd:c}) ]] \ + || builtin which -a "$realcmd" | command grep -Fx -q "$editorcmd"; then + editorcmd="$cmd" # replace $editorcmd with the typed command so it matches below fi - # Preserve beginning space - LBUFFER="${WHITESPACE}${LBUFFER}" + # Check for editor commands in the typed command and replace accordingly + case "$BUFFER" in + $editorcmd\ *) __sudo-replace-buffer "$editorcmd" "sudoedit" ;; + \$EDITOR\ *) __sudo-replace-buffer '$EDITOR' "sudoedit" ;; + sudoedit\ *) __sudo-replace-buffer "sudoedit" "$EDITOR" ;; + sudo\ *) __sudo-replace-buffer "sudo" "" ;; + *) LBUFFER="sudo $LBUFFER" ;; + esac + fi + + # Preserve beginning space + LBUFFER="${WHITESPACE}${LBUFFER}" + + # Redisplay edit buffer (compatibility with zsh-syntax-highlighting) + zle redisplay } zle -N sudo-command-line diff --git a/plugins/suse/README.md b/plugins/suse/README.md index b9b069574..06c6d9ef5 100644 --- a/plugins/suse/README.md +++ b/plugins/suse/README.md @@ -2,9 +2,9 @@ **Maintainer**: [r-darwish](https://github.com/r-darwish) - Alias for Zypper according to the official Zypper's alias +Alias for Zypper according to the official Zypper's alias - To use it add `suse` to the plugins array in you zshrc file. +To use it add `suse` to the plugins array in you zshrc file. ```zsh plugins=(... suse) @@ -60,6 +60,12 @@ plugins=(... suse) | zse | `zypper se` | search for packages | | zwp | `zypper wp` | list all packages providing the specified capability | +NOTE: `--no-refresh` is passed to zypper for speeding up the calls and avoid errors due to lack +of root privileges. If you need to refresh the repositories, call `sudo zypper ref` (`zref` alias) +before runing these aliases. + +Related: [#9798](https://github.com/ohmyzsh/ohmyzsh/pull/9798). + ## Repositories commands | Alias | Commands | Description | diff --git a/plugins/suse/suse.plugin.zsh b/plugins/suse/suse.plugin.zsh index dcfeccb03..56bc6f1c5 100644 --- a/plugins/suse/suse.plugin.zsh +++ b/plugins/suse/suse.plugin.zsh @@ -25,16 +25,16 @@ alias zup='sudo zypper up' alias zpatch='sudo zypper patch' #Request commands -alias zif='zypper if' -alias zpa='zypper pa' -alias zpatch-info='zypper patch-info' -alias zpattern-info='zypper pattern-info' -alias zproduct-info='zypper product-info' -alias zpch='zypper pch' -alias zpd='zypper pd' -alias zpt='zypper pt' -alias zse='zypper se' -alias zwp='zypper wp' +alias zif='zypper --no-refresh if' +alias zpa='zypper --no-refresh pa' +alias zpatch-info='zypper --no-refresh patch-info' +alias zpattern-info='zypper --no-refresh pattern-info' +alias zproduct-info='zypper --no-refresh product-info' +alias zpch='zypper --no-refresh pch' +alias zpd='zypper --no-refresh pd' +alias zpt='zypper --no-refresh pt' +alias zse='zypper --no-refresh se' +alias zwp='zypper --no-refresh wp' #Repositories commands alias zar='sudo zypper ar' diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh index 010f998d3..53ec453e8 100644 --- a/plugins/vim-interaction/vim-interaction.plugin.zsh +++ b/plugins/vim-interaction/vim-interaction.plugin.zsh @@ -22,7 +22,8 @@ EOH local cmd="" local before="<esc>" local after="" - local name="GVIM" + # Look up the newest instance + local name="$(gvim --serverlist | tail -n 1)" while getopts ":b:a:n:" option do case $option in |