From 9c34c359c4c1ebb1bd0211d40c3bca0c6aa2ca97 Mon Sep 17 00:00:00 2001 From: Aayush Kapoor Date: Fri, 6 Aug 2021 19:21:19 +0530 Subject: [PATCH 01/59] chore(ag): fix README (#10001) --- plugins/ag/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ag/README.md b/plugins/ag/README.md index 6acc54067..1983aaa41 100644 --- a/plugins/ag/README.md +++ b/plugins/ag/README.md @@ -5,7 +5,7 @@ This plugin provides completion support for [`ag`](https://github.com/ggreer/the To use it, add ag to the plugins array in your zshrc file. ```zsh -plugins=(... aws) +plugins=(... ag) ``` ## INSTALLATION NOTES From ab58594173c04f7fe2155a169d8906ef761ba0fc Mon Sep 17 00:00:00 2001 From: Max Eisner <4730112+max-ae@users.noreply.github.com> Date: Tue, 10 Aug 2021 16:31:49 +0200 Subject: [PATCH 02/59] feat(git): add `develop` branch name detection (#9881) --- plugins/git/README.md | 35 ++++++++++++++++++----------------- plugins/git/git.plugin.zsh | 19 ++++++++++++++++--- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index e00f4cf92..522257d2d 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)\|development\|develop\|devel\|dev)\s*$)" \| command xargs -n 1 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 | | gbD | git branch -D | | gbl | git blame -b -w | | gbnm | git branch --no-merged | @@ -49,8 +49,8 @@ plugins=(... git) | gcl | git clone --recurse-submodules | | gclean | git clean -id | | gpristine | git reset --hard && git clean -dffx | -| gcm | git checkout $(git_main_branch) | -| gcd | git checkout develop | +| gcm | git checkout $(git_main_branch) | +| gcd | git checkout $(git_develop_branch) | | gcmsg | git commit -m | | gco | git checkout | | gcor | git checkout --recurse-submodules | @@ -88,7 +88,7 @@ plugins=(... git) | ghh | git help | | gignore | git update-index --assume-unchanged | | gignored | git ls-files -v \| grep "^[[:lower:]]" | -| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk | +| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk | | gk | gitk --all --branches | | gke | gitk --all $(git log -g --pretty=%h) | | gl | git pull | @@ -107,10 +107,10 @@ plugins=(... git) | gloga | git log --oneline --decorate --graph --all | | glp | git log --pretty=\ | | gm | git merge | -| gmom | git merge origin/$(git_main_branch) | +| gmom | git merge origin/$(git_main_branch) | | gmt | git mergetool --no-prompt | | gmtvim | git mergetool --no-prompt --tool=vimdiff | -| gmum | git merge upstream/$(git_main_branch) | +| gmum | git merge upstream/$(git_main_branch) | | gma | git merge --abort | | gp | git push | | gpd | git push --dry-run | @@ -125,10 +125,10 @@ plugins=(... git) | grb | git rebase | | grba | git rebase --abort | | grbc | git rebase --continue | -| grbd | git rebase develop | +| grbd | git rebase $(git_develop_branch) | | grbi | git rebase -i | -| grbm | git rebase $(git_main_branch) | -| grbo | git rebase --onto | +| grbm | git rebase $(git_main_branch) | +| grbo | git rebase --onto | | grbs | git rebase --skip | | grev | git revert | | grh | git reset | @@ -176,7 +176,7 @@ plugins=(... git) | gupv | git pull --rebase -v | | gupa | git pull --rebase --autostash | | gupav | git pull --rebase --autostash -v | -| glum | git pull upstream $(git_main_branch) | +| glum | git pull upstream $(git_main_branch) | | gwch | git whatchanged -p --abbrev-commit --pretty=medium | | gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" | | gam | git am | @@ -214,13 +214,14 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa ### Current -| Command | Description | -|:-----------------------|:-----------------------------------------------------------------------------| -| `grename ` | Rename `old` branch to `new`, including in origin remote | -| current_branch | Return the name of the current branch | -| git_current_user_name | Returns the `user.name` config value | -| git_current_user_email | Returns the `user.email` config value | -| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise | +| Command | Description | +|:-----------------------|:---------------------------------------------------------------------------------------------------------| +| `grename ` | Rename `old` branch to `new`, including in origin remote | +| current_branch | Return the name of the current branch | +| git_current_user_name | Returns the `user.name` config value | +| git_current_user_email | Returns the `user.email` config value | +| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise | +| git_develop_branch | Returns the name of the develop branch: `dev`, `devel`, `development` if they exist, `develop` otherwise | ### Work in Progress (WIP) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 2a7c7290d..3cd558692 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -42,6 +42,19 @@ function git_main_branch() { echo master } +# Check for develop and similarly named branches +function git_develop_branch() { + command git rev-parse --git-dir &>/dev/null || return + local branch + for branch in dev devel development; do + if command git show-ref -q --verify refs/heads/$branch; then + echo $branch + return + fi + done + echo develop +} + # # Aliases # (sorted alphabetically) @@ -60,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)|development|develop|devel|dev)\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 -n 1 git branch -d' alias gbD='git branch -D' alias gbl='git blame -b -w' alias gbnm='git branch --no-merged' @@ -88,7 +101,7 @@ alias gcl='git clone --recurse-submodules' alias gclean='git clean -id' alias gpristine='git reset --hard && git clean -dffx' alias gcm='git checkout $(git_main_branch)' -alias gcd='git checkout develop' +alias gcd='git checkout $(git_develop_branch)' alias gcmsg='git commit -m' alias gco='git checkout' alias gcor='git checkout --recurse-submodules' @@ -227,7 +240,7 @@ alias gra='git remote add' alias grb='git rebase' alias grba='git rebase --abort' alias grbc='git rebase --continue' -alias grbd='git rebase develop' +alias grbd='git rebase $(git_develop_branch)' alias grbi='git rebase -i' alias grbm='git rebase $(git_main_branch)' alias grbo='git rebase --onto' From bca73e18584771fd6db770055dac25b5728764c3 Mon Sep 17 00:00:00 2001 From: Quentin Nerden Date: Tue, 10 Aug 2021 20:25:08 +0200 Subject: [PATCH 03/59] feat(plugins): add completion plugin for `invoke` (#7311) Co-authored-by: Quentin Nerden --- plugins/invoke/README.md | 10 ++++++++++ plugins/invoke/invoke.plugin.zsh | 5 +++++ 2 files changed, 15 insertions(+) create mode 100644 plugins/invoke/README.md create mode 100644 plugins/invoke/invoke.plugin.zsh diff --git a/plugins/invoke/README.md b/plugins/invoke/README.md new file mode 100644 index 000000000..3f4b88078 --- /dev/null +++ b/plugins/invoke/README.md @@ -0,0 +1,10 @@ +# Invoke plugin + +This plugin adds completion for [invoke](https://github.com/pyinvoke/invoke). + +To use it, add `invoke` to the plugins array in your `~/.zshrc` file: + +```zsh +plugins=(... invoke) +``` + diff --git a/plugins/invoke/invoke.plugin.zsh b/plugins/invoke/invoke.plugin.zsh new file mode 100644 index 000000000..8c807de02 --- /dev/null +++ b/plugins/invoke/invoke.plugin.zsh @@ -0,0 +1,5 @@ +# Autocompletion for invoke. +# +if [ $commands[invoke] ]; then + source <(invoke --print-completion-script=zsh) +fi From b79fba7b0d38aa61afaeeaaa7fab6992dbfb6db3 Mon Sep 17 00:00:00 2001 From: Gregor Trefs Date: Tue, 10 Aug 2021 21:02:06 +0200 Subject: [PATCH 04/59] feat(plugins): `octozen` shows an Octocat zen quote on startup (#5959) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/octozen/README.md | 12 ++++++++++++ plugins/octozen/octozen.plugin.zsh | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 plugins/octozen/README.md create mode 100644 plugins/octozen/octozen.plugin.zsh diff --git a/plugins/octozen/README.md b/plugins/octozen/README.md new file mode 100644 index 000000000..2051248ca --- /dev/null +++ b/plugins/octozen/README.md @@ -0,0 +1,12 @@ +# Octozen plugin + +Displays a zen quote from GitHub's Octocat on start up. + +To use it, add `octozen` to the plugins array in your zshrc file: + +```zsh +plugins=(... octozen) +``` + +It defines a `display_octozen` function that fetches a GitHub Octocat zen quote. +NOTE: Internet connection is required (will time out if not fetched in 2 seconds). diff --git a/plugins/octozen/octozen.plugin.zsh b/plugins/octozen/octozen.plugin.zsh new file mode 100644 index 000000000..71ee550a5 --- /dev/null +++ b/plugins/octozen/octozen.plugin.zsh @@ -0,0 +1,11 @@ +# octozen plugin + +# Displays a zen quote from octocat +function display_octozen() { + curl -m 2 -fsL "https://api.github.com/octocat" + add-zsh-hook -d precmd display_octozen +} + +# Display the octocat on the first precmd, after the whole starting process has finished +autoload -Uz add-zsh-hook +add-zsh-hook precmd display_octozen From c24928815179e1a8e1e3a0a4ab130e22ba2e0f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 10 Aug 2021 21:05:00 +0200 Subject: [PATCH 05/59] feat(lib): add `mkcd` as equivalent to `takedir` (#9749) Fixes #9749 --- lib/functions.zsh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 9cc735196..24b7254fb 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -13,10 +13,6 @@ function upgrade_oh_my_zsh() { omz update } -function takedir() { - mkdir -p $@ && cd ${@:$#} -} - function open_command() { local open_cmd @@ -37,6 +33,13 @@ function open_command() { ${=open_cmd} "$@" &>/dev/null } +# take functions + +# mkcd is equivalent to takedir +function mkcd takedir() { + mkdir -p $@ && cd ${@:$#} +} + function takeurl() { data=$(mktemp) curl -L $1 > $data From 7eeb1e193d4a55ab706931fb80ef556a939be8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 10 Aug 2021 21:09:21 +0200 Subject: [PATCH 06/59] refactor(lib): refactor take functions --- lib/functions.zsh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 24b7254fb..73b491a59 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -41,26 +41,27 @@ function mkcd takedir() { } function takeurl() { - data=$(mktemp) - curl -L $1 > $data - tar xf $data - thedir=$(tar tf $data | head -1) - rm $data - cd $thedir + local data thedir + data="$(mktemp)" + curl -L "$1" > "$data" + tar xf "$data" + thedir="$(tar tf "$data" | head -1)" + rm "$data" + cd "$thedir" } function takegit() { - git clone $1 - cd $(basename ${1%%.git}) + git clone "$1" + cd "$(basename ${1%%.git})" } function take() { if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then - takeurl $1 + takeurl "$1" elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then - takegit $1 + takegit "$1" else - takedir $1 + takedir "$@" fi } From 6e4c9df4a433849a2c636980dc317db0fba3a0f5 Mon Sep 17 00:00:00 2001 From: James Eapen Date: Fri, 13 Aug 2021 06:33:30 -0400 Subject: [PATCH 07/59] feat(cli): add `plugin load` subcommand (#9872) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #9672 Co-authored-by: Marc Cornellà --- lib/cli.zsh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 5 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index 38e2f72f8..7e3e37be8 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -37,7 +37,7 @@ function _omz { changelog) local -a refs refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}") _describe 'command' refs ;; - plugin) subcmds=('info:Get plugin information' 'list:List plugins') + plugin) subcmds=('info:Get plugin information' 'list:List plugins' 'load:Load plugin(s)') _describe 'command' subcmds ;; pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches') _describe 'command' subcmds ;; @@ -46,10 +46,26 @@ function _omz { esac elif (( CURRENT == 4 )); then case "$words[2]::$words[3]" in - plugin::info) compadd "$ZSH"/plugins/*/README.md(.N:h:t) \ - "$ZSH_CUSTOM"/plugins/*/README.md(.N:h:t) ;; - theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \ - "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;; + plugin::(info|load)) + local -aU plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) + _describe 'plugin' plugins ;; + theme::use) + local -aU themes=("$ZSH"/themes/*.zsh-theme(.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)) + _describe 'theme' themes ;; + esac + elif (( CURRENT > 4 )); then + case "$words[2]::$words[3]" in + plugin::load) + local -aU plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) + + # Remove plugins already passed as arguments + # NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which + # has a space after them. This is to avoid removing plugins partially passed, which makes + # the completion not add a space after the completed plugin. + local -a args=(${words[4,$(( CURRENT - 1))]}) + plugins=(${plugins:|args}) + + _describe 'plugin' plugins ;; esac fi @@ -147,6 +163,7 @@ Available commands: info Get information of a plugin list List all available Oh My Zsh plugins + load Load plugin(s) EOF return 1 @@ -205,6 +222,56 @@ function _omz::plugin::list { fi } +function _omz::plugin::load { + if [[ -z "$1" ]]; then + echo >&2 "Usage: omz plugin load [...]" + return 1 + fi + + local plugins=("$@") + local plugin base has_completion=0 + + for plugin in $plugins; do + if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then + base="$ZSH_CUSTOM/plugins/$plugin" + elif [[ -d "$ZSH/plugins/$plugin" ]]; then + base="$ZSH/plugins/$plugin" + else + _omz::log warn "plugin '$plugin' not found" + continue + fi + + # Check if its a valid plugin + if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then + _omz::log warn "'$plugin' is not a valid plugin" + continue + # It it is a valid plugin, add its directory to $fpath unless it is already there + elif (( ! ${fpath[(Ie)$base]} )); then + fpath=("$base" $fpath) + fi + + # Check if it has completion to reload compinit + if [[ -f "$base/_$plugin" ]]; then + has_completion=1 + fi + + # Load the plugin + if [[ -f "$base/$plugin.plugin.zsh" ]]; then + source "$base/$plugin.plugin.zsh" + fi + done + + # If we have completion, we need to reload the completion + # We pass -D to avoid generating a new dump file, which would overwrite our + # current one for the next session (and we don't want that because we're not + # actually enabling the plugins for the next session). + # Note that we still have to pass -d "$_comp_dumpfile", so that compinit + # doesn't use the default zcompdump location (${ZDOTDIR:-$HOME}/.zcompdump). + if (( has_completion )); then + compinit -D -d "$_comp_dumpfile" + fi +} + function _omz::pr { (( $# > 0 && $+functions[_omz::pr::$1] )) || { cat < Date: Fri, 13 Aug 2021 12:38:22 +0200 Subject: [PATCH 08/59] refactor(fedora)!: remove deprecated `fedora` plugin BREAKING CHANGE: the `fedora` plugin has been removed. Use the `dnf` plugin instead. --- plugins/fedora/README.md | 1 - plugins/fedora/fedora.plugin.zsh | 3 --- 2 files changed, 4 deletions(-) delete mode 100644 plugins/fedora/README.md delete mode 100644 plugins/fedora/fedora.plugin.zsh diff --git a/plugins/fedora/README.md b/plugins/fedora/README.md deleted file mode 100644 index 85d8d7dea..000000000 --- a/plugins/fedora/README.md +++ /dev/null @@ -1 +0,0 @@ -The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dnf) instead. diff --git a/plugins/fedora/fedora.plugin.zsh b/plugins/fedora/fedora.plugin.zsh deleted file mode 100644 index 226506c05..000000000 --- a/plugins/fedora/fedora.plugin.zsh +++ /dev/null @@ -1,3 +0,0 @@ -print -P "%F{yellow}The 'fedora' plugin is deprecated. Use the '%Udnf%u' plugin instead.%f" - -source "$ZSH/plugins/dnf/dnf.plugin.zsh" From e1f0d826f1f0d362eb377ef4a8124062ec63c3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 13 Aug 2021 12:40:20 +0200 Subject: [PATCH 09/59] refactor(go)!: remove deprecated `go` plugin BREAKING CHANGE: the `go` plugin has been removed. Use the `golang` plugin instead. --- plugins/go/README.md | 1 - plugins/go/go.plugin.zsh | 3 --- 2 files changed, 4 deletions(-) delete mode 100644 plugins/go/README.md delete mode 100644 plugins/go/go.plugin.zsh diff --git a/plugins/go/README.md b/plugins/go/README.md deleted file mode 100644 index bf43b9feb..000000000 --- a/plugins/go/README.md +++ /dev/null @@ -1 +0,0 @@ -The go plugin is deprecated. Use the [golang plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/golang) instead. diff --git a/plugins/go/go.plugin.zsh b/plugins/go/go.plugin.zsh deleted file mode 100644 index da7c87cfd..000000000 --- a/plugins/go/go.plugin.zsh +++ /dev/null @@ -1,3 +0,0 @@ -print -P "%F{yellow}The 'go' plugin is deprecated. Use the '%Ugolang%u' plugin instead.%f" - -source "$ZSH/plugins/golang/golang.plugin.zsh" From af6c7f3d6782cf0a34e4e68f661df526d35795be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 13 Aug 2021 12:42:56 +0200 Subject: [PATCH 10/59] refactor(cloudapp)!: remove deprecated `cloudapp` plugin BREAKING CHANGE: the `cloudapp` plugin has been removed due to removed API. --- plugins/cloudapp/README.md | 26 -------------------------- plugins/cloudapp/cloudapp.plugin.zsh | 4 ---- 2 files changed, 30 deletions(-) delete mode 100644 plugins/cloudapp/README.md delete mode 100644 plugins/cloudapp/cloudapp.plugin.zsh diff --git a/plugins/cloudapp/README.md b/plugins/cloudapp/README.md deleted file mode 100644 index ef304edc2..000000000 --- a/plugins/cloudapp/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# CloudApp plugin - -## The CloudApp API is deprecated, so the plugin will be removed shortly - -[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line. - -To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file: - -```zsh -plugins=(... cloudapp) -``` - -## Requirements - -1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation) - -2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below: - ``` - email - password - ``` - -## Usage - -- `cloudapp `: uploads `` to your CloudApp account, and if you're using - macOS, copies the URL to your clipboard. diff --git a/plugins/cloudapp/cloudapp.plugin.zsh b/plugins/cloudapp/cloudapp.plugin.zsh deleted file mode 100644 index a4d92a080..000000000 --- a/plugins/cloudapp/cloudapp.plugin.zsh +++ /dev/null @@ -1,4 +0,0 @@ -print -Pn "%F{yellow}" -print "[oh-my-zsh] The CloudApp API no longer works, so the cloudapp plugin will" -print "[oh-my-zsh] be removed shortly. Please remove it from your plugins list." -print -Pn "%f" From 6dc937ff685fcbc43056dbd7fb05ba01c56dfd1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 4 Aug 2021 15:49:11 +0200 Subject: [PATCH 11/59] feat(extract): add suport for .cab files via `cabextract` --- plugins/extract/README.md | 1 + plugins/extract/_extract | 2 +- plugins/extract/extract.plugin.zsh | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/extract/README.md b/plugins/extract/README.md index f2e6ad1d1..1dd8e19c0 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -21,6 +21,7 @@ plugins=(... extract) | `apk` | Android app file | | `aar` | Android library file | | `bz2` | Bzip2 file | +| `cab` | Microsoft cabinet archive | | `deb` | Debian package | | `ear` | Enterprise Application aRchive | | `gz` | Gzip file | diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 267c4d4e1..31a7facbe 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,5 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ + "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ && return 0 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index e390e2dcc..601272cac 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -55,7 +55,7 @@ extract() { (*.lz4) lz4 -d "$1" ;; (*.lzma) unlzma "$1" ;; (*.z) uncompress "$1" ;; - (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; + (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d "$extract_dir" ;; (*.rar) unrar x -ad "$1" ;; (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; (*.7z) 7za x "$1" ;; @@ -69,6 +69,7 @@ extract() { cd .. ;; (*.zst) unzstd "$1" ;; + (*.cab) cabextract -d "$extract_dir" "$1" ;; (*) echo "extract: '$1' cannot be extracted" >&2 success=1 From 59a9b453d348baad4ff7b7cb2e1f205d615200e6 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuna Date: Mon, 24 Jun 2019 00:54:28 +0300 Subject: [PATCH 12/59] fix(extract): support unpacking deb file from different directory --- plugins/extract/extract.plugin.zsh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 601272cac..e63b9494f 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -60,13 +60,13 @@ extract() { (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; (*.7z) 7za x "$1" ;; (*.deb) - mkdir -p "$extract_dir/control" - mkdir -p "$extract_dir/data" - cd "$extract_dir"; ar vx "../${1}" > /dev/null - cd control; tar xzvf ../control.tar.gz - cd ../data; extract ../data.tar.* - cd ..; rm *.tar.* debian-binary - cd .. + local pwd="$PWD" file="${1:A}" + mkdir -p "$extract_dir/control" "$extract_dir/data" + builtin cd -q "$extract_dir"; ar vx "$file" > /dev/null + builtin cd -q control; extract ../control.tar.* + builtin cd -q ../data; extract ../data.tar.* + builtin cd -q ..; command rm *.tar.* debian-binary + builtin cd -q "$pwd" ;; (*.zst) unzstd "$1" ;; (*.cab) cabextract -d "$extract_dir" "$1" ;; From 0b506fea0c9aeb450db6fdaba572041fd900c05b Mon Sep 17 00:00:00 2001 From: Xeonacid Date: Wed, 9 Jun 2021 19:29:04 +0800 Subject: [PATCH 13/59] feat(extract): add cpio support --- plugins/extract/README.md | 1 + plugins/extract/_extract | 2 +- plugins/extract/extract.plugin.zsh | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/extract/README.md b/plugins/extract/README.md index 1dd8e19c0..44f0b05a1 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -22,6 +22,7 @@ plugins=(... extract) | `aar` | Android library file | | `bz2` | Bzip2 file | | `cab` | Microsoft cabinet archive | +| `cpio` | Cpio archive | | `deb` | Debian package | | `ear` | Enterprise Application aRchive | | `gz` | Gzip file | diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 31a7facbe..27b099c9e 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,5 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ + "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ && return 0 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index e63b9494f..ac181fa78 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -70,6 +70,7 @@ extract() { ;; (*.zst) unzstd "$1" ;; (*.cab) cabextract -d "$extract_dir" "$1" ;; + (*.cpio) cpio -idmvF "$1" ;; (*) echo "extract: '$1' cannot be extracted" >&2 success=1 From a2f1ef69b570b43bbdd0fa29bddb860293b7278b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 14 Aug 2021 21:57:56 +0200 Subject: [PATCH 14/59] fix(extract): correctly extract rpm files on other directories --- plugins/extract/extract.plugin.zsh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index ac181fa78..12a1ec948 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -20,6 +20,7 @@ extract() { shift fi + local pwd="$PWD" while (( $# > 0 )); do if [[ ! -f "$1" ]]; then echo "extract: '$1' is not a valid file" >&2 @@ -29,6 +30,7 @@ extract() { success=0 extract_dir="${1:t:r}" + local full_path="${1:A}" case "${1:l}" in (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; @@ -57,17 +59,16 @@ extract() { (*.z) uncompress "$1" ;; (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d "$extract_dir" ;; (*.rar) unrar x -ad "$1" ;; - (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; + (*.rpm) + command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \ + && rpm2cpio "$full_path" | cpio --quiet -id ;; (*.7z) 7za x "$1" ;; (*.deb) - local pwd="$PWD" file="${1:A}" - mkdir -p "$extract_dir/control" "$extract_dir/data" - builtin cd -q "$extract_dir"; ar vx "$file" > /dev/null + command mkdir -p "$extract_dir/control" "$extract_dir/data" + builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null builtin cd -q control; extract ../control.tar.* builtin cd -q ../data; extract ../data.tar.* - builtin cd -q ..; command rm *.tar.* debian-binary - builtin cd -q "$pwd" - ;; + builtin cd -q ..; command rm *.tar.* debian-binary ;; (*.zst) unzstd "$1" ;; (*.cab) cabextract -d "$extract_dir" "$1" ;; (*.cpio) cpio -idmvF "$1" ;; @@ -77,8 +78,11 @@ extract() { ;; esac - (( success = $success > 0 ? $success : $? )) - (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" + (( success = success > 0 ? success : $? )) + (( success == 0 && remove_archive == 0 )) && rm "$full_path" shift + + # Go back to original working directory in case we ran cd previously + builtin cd -q "$pwd" done } From 10a00085d027a969c7ef27e52085ca1fa7f5668c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 14 Aug 2021 22:05:48 +0200 Subject: [PATCH 15/59] fix(extract): don't push entries to dirstack when extracting rpm and deb files --- plugins/extract/extract.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 12a1ec948..a257f6bc3 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -1,6 +1,8 @@ alias x=extract extract() { + setopt localoptions noautopushd + local remove_archive local success local extract_dir From 0b32e4b25fa7f3215964281a8af4e3ff2bf4cd68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 14 Aug 2021 22:03:41 +0200 Subject: [PATCH 16/59] style(extract): adopt main code style guide and refactor variables --- plugins/extract/extract.plugin.zsh | 153 ++++++++++++++--------------- 1 file changed, 74 insertions(+), 79 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index a257f6bc3..1112dd52f 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -1,90 +1,85 @@ alias x=extract extract() { - setopt localoptions noautopushd + setopt localoptions noautopushd - local remove_archive - local success - local extract_dir + if (( $# == 0 )); then + cat >&2 <<'EOF' +Usage: extract [-option] [file ...] - if (( $# == 0 )); then - cat <<-'EOF' >&2 - Usage: extract [-option] [file ...] +Options: + -r, --remove Remove archive after unpacking. +EOF + fi - Options: - -r, --remove Remove archive after unpacking. - EOF - fi + local remove_archive=1 + if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then + remove_archive=0 + shift + fi - remove_archive=1 - if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then - remove_archive=0 - shift - fi + local pwd="$PWD" + while (( $# > 0 )); do + if [[ ! -f "$1" ]]; then + echo "extract: '$1' is not a valid file" >&2 + shift + continue + fi - local pwd="$PWD" - while (( $# > 0 )); do - if [[ ! -f "$1" ]]; then - echo "extract: '$1' is not a valid file" >&2 - shift - continue - fi + local success=0 + local extract_dir="${1:t:r}" + local file="$1" full_path="${1:A}" + case "${file:l}" in + (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$file" | tar xv } || tar zxvf "$file" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$file" ;; + (*.tar.xz|*.txz) + tar --xz --help &> /dev/null \ + && tar --xz -xvf "$file" \ + || xzcat "$file" | tar xvf - ;; + (*.tar.zma|*.tlz) + tar --lzma --help &> /dev/null \ + && tar --lzma -xvf "$file" \ + || lzcat "$file" | tar xvf - ;; + (*.tar.zst|*.tzst) + tar --zstd --help &> /dev/null \ + && tar --zstd -xvf "$file" \ + || zstdcat "$file" | tar xvf - ;; + (*.tar) tar xvf "$file" ;; + (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$file" ;; + (*.tar.lz4) lz4 -c -d "$file" | tar xvf - ;; + (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$file" ;; + (*.gz) (( $+commands[pigz] )) && pigz -dk "$file" || gunzip -k "$file" ;; + (*.bz2) bunzip2 "$file" ;; + (*.xz) unxz "$file" ;; + (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$file" ;; + (*.lz4) lz4 -d "$file" ;; + (*.lzma) unlzma "$file" ;; + (*.z) uncompress "$file" ;; + (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$file" -d "$extract_dir" ;; + (*.rar) unrar x -ad "$file" ;; + (*.rpm) + command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \ + && rpm2cpio "$full_path" | cpio --quiet -id ;; + (*.7z) 7za x "$file" ;; + (*.deb) + command mkdir -p "$extract_dir/control" "$extract_dir/data" + builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null + builtin cd -q control; extract ../control.tar.* + builtin cd -q ../data; extract ../data.tar.* + builtin cd -q ..; command rm *.tar.* debian-binary ;; + (*.zst) unzstd "$file" ;; + (*.cab) cabextract -d "$extract_dir" "$file" ;; + (*.cpio) cpio -idmvF "$file" ;; + (*) + echo "extract: '$file' cannot be extracted" >&2 + success=1 ;; + esac - success=0 - extract_dir="${1:t:r}" - local full_path="${1:A}" - case "${1:l}" in - (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; - (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; - (*.tar.xz|*.txz) - tar --xz --help &> /dev/null \ - && tar --xz -xvf "$1" \ - || xzcat "$1" | tar xvf - ;; - (*.tar.zma|*.tlz) - tar --lzma --help &> /dev/null \ - && tar --lzma -xvf "$1" \ - || lzcat "$1" | tar xvf - ;; - (*.tar.zst|*.tzst) - tar --zstd --help &> /dev/null \ - && tar --zstd -xvf "$1" \ - || zstdcat "$1" | tar xvf - ;; - (*.tar) tar xvf "$1" ;; - (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;; - (*.tar.lz4) lz4 -c -d "$1" | tar xvf - ;; - (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$1" ;; - (*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;; - (*.bz2) bunzip2 "$1" ;; - (*.xz) unxz "$1" ;; - (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$1" ;; - (*.lz4) lz4 -d "$1" ;; - (*.lzma) unlzma "$1" ;; - (*.z) uncompress "$1" ;; - (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d "$extract_dir" ;; - (*.rar) unrar x -ad "$1" ;; - (*.rpm) - command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \ - && rpm2cpio "$full_path" | cpio --quiet -id ;; - (*.7z) 7za x "$1" ;; - (*.deb) - command mkdir -p "$extract_dir/control" "$extract_dir/data" - builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null - builtin cd -q control; extract ../control.tar.* - builtin cd -q ../data; extract ../data.tar.* - builtin cd -q ..; command rm *.tar.* debian-binary ;; - (*.zst) unzstd "$1" ;; - (*.cab) cabextract -d "$extract_dir" "$1" ;; - (*.cpio) cpio -idmvF "$1" ;; - (*) - echo "extract: '$1' cannot be extracted" >&2 - success=1 - ;; - esac + (( success = success > 0 ? success : $? )) + (( success == 0 && remove_archive == 0 )) && rm "$full_path" + shift - (( success = success > 0 ? success : $? )) - (( success == 0 && remove_archive == 0 )) && rm "$full_path" - shift - - # Go back to original working directory in case we ran cd previously - builtin cd -q "$pwd" - done + # Go back to original working directory in case we ran cd previously + builtin cd -q "$pwd" + done } From 7c5ab01a5f7b07481182108117db070b8cabb2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 14 Aug 2021 22:41:48 +0200 Subject: [PATCH 17/59] fix(changelog): also display commits from merged branches --- tools/changelog.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/changelog.sh b/tools/changelog.sh index 56ea42cb1..6913ae49a 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -391,9 +391,7 @@ function main { # Get commit list from $until commit until $since commit, or until root # commit if $since is unset, in short hash form. - # --first-parent is used when dealing with merges: it only prints the - # merge commit, not the commits of the merged branch. - command git rev-list --first-parent --abbrev-commit --abbrev=7 ${since:+$since..}$until | while read hash; do + command git rev-list --abbrev-commit --abbrev=7 ${since:+$since..}$until | while read hash; do # Truncate list on versions with a lot of commits if [[ -z "$since" ]] && (( ++read_commits > 35 )); then truncate=1 From 11e22ed0b5c1aebd6e990ea7a885bdf03ab6555a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 14 Aug 2021 22:54:07 +0200 Subject: [PATCH 18/59] docs(dirhistory): document keyboard shortcut conflict with Windows Terminal Related: https://github.com/ohmyzsh/ohmyzsh/issues/8505#issuecomment-886241162 --- plugins/dirhistory/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/dirhistory/README.md b/plugins/dirhistory/README.md index 223650727..602fc8284 100644 --- a/plugins/dirhistory/README.md +++ b/plugins/dirhistory/README.md @@ -17,6 +17,9 @@ plugins=(... dirhistory) | alt + up | Move into the parent directory | | alt + down | Move into the first child directory by alphabetical order | +NOTE: some terminals might override the ALT+Arrows key bindings (Windows Terminal, for example). +If these don't work check your terminal settings and change them to a different keyboard shortcut. + ## Usage This plugin allows you to navigate the history of previous current-working-directories using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. MAC users may alternately use OPT-LEFT and OPT-RIGHT. From 33847956d9969866dd8b502ffc88af58d2b427fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 17 Aug 2021 09:37:01 +0200 Subject: [PATCH 19/59] fix(colemak): remove `lesskey` usage in less v582 and newer (#10102) --- plugins/colemak/.gitignore | 1 + plugins/colemak/colemak.plugin.zsh | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 plugins/colemak/.gitignore 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 From 4455c13e063cf81ba427f98e1dce2024ecd50762 Mon Sep 17 00:00:00 2001 From: pollyduan Date: Tue, 17 Aug 2021 18:10:54 +0800 Subject: [PATCH 20/59] feat(cli): add subcommands for plugin `enable` and `disable` (#9869) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- lib/cli.zsh | 218 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 207 insertions(+), 11 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index 7e3e37be8..1289df730 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -37,7 +37,13 @@ function _omz { changelog) local -a refs refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}") _describe 'command' refs ;; - plugin) subcmds=('info:Get plugin information' 'list:List plugins' 'load:Load plugin(s)') + plugin) subcmds=( + 'disable:Disable plugin(s)' + 'enable:Enable plugin(s)' + 'info:Get plugin information' + 'list:List plugins' + 'load:Load plugin(s)' + ) _describe 'command' subcmds ;; pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches') _describe 'command' subcmds ;; @@ -45,8 +51,21 @@ function _omz { _describe 'command' subcmds ;; esac elif (( CURRENT == 4 )); then - case "$words[2]::$words[3]" in - plugin::(info|load)) + case "${words[2]}::${words[3]}" in + plugin::(disable|enable|load)) + local -aU valid_plugins + + if [[ "${words[3]}" = disable ]]; then + # if command is "disable", only offer already enabled plugins + valid_plugins=($plugins) + else + valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) + # if command is "enable", remove already enabled plugins + [[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins}) + fi + + _describe 'plugin' valid_plugins ;; + plugin::info) local -aU plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) _describe 'plugin' plugins ;; theme::use) @@ -54,18 +73,27 @@ function _omz { _describe 'theme' themes ;; esac elif (( CURRENT > 4 )); then - case "$words[2]::$words[3]" in - plugin::load) - local -aU plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) + case "${words[2]}::${words[3]}" in + plugin::(enable|disable|load)) + local -aU valid_plugins + + if [[ "${words[3]}" = disable ]]; then + # if command is "disable", only offer already enabled plugins + valid_plugins=($plugins) + else + valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) + # if command is "enable", remove already enabled plugins + [[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins}) + fi # Remove plugins already passed as arguments # NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which # has a space after them. This is to avoid removing plugins partially passed, which makes # the completion not add a space after the completed plugin. local -a args=(${words[4,$(( CURRENT - 1))]}) - plugins=(${plugins:|args}) + valid_plugins=(${valid_plugins:|args}) - _describe 'plugin' plugins ;; + _describe 'plugin' valid_plugins ;; esac fi @@ -161,9 +189,11 @@ Usage: omz plugin [options] Available commands: - info Get information of a plugin - list List all available Oh My Zsh plugins - load Load plugin(s) + disable Disable plugin(s) + enable Enable plugin(s) + info Get information of a plugin + list List all available Oh My Zsh plugins + load Load plugin(s) EOF return 1 @@ -175,6 +205,172 @@ EOF _omz::plugin::$command "$@" } +function _omz::plugin::disable { + if [[ -z "$1" ]]; then + echo >&2 "Usage: omz plugin disable [...]" + return 1 + fi + + # Check that plugin is in $plugins + local -a dis_plugins=() + for plugin in "$@"; do + if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then + _omz::log warn "plugin '$plugin' is not enabled." + continue + fi + dis_plugins+=("$plugin") + done + + # Exit if there are no enabled plugins to disable + if [[ ${#dis_plugins} -eq 0 ]]; then + return 1 + fi + + # Disable plugins awk script + local awk_script=" +# if plugins=() is in oneline form, substitute disabled plugins and go to next line +/^\s*plugins=\([^#]+\).*\$/ { + sub(/\s+(${(j:|:)dis_plugins})/, \"\") # with spaces before + sub(/(${(j:|:)dis_plugins})\s+/, \"\") # with spaces after + sub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin) + print \$0 + next +} + +# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there +/^\s*plugins=\(/ { + multi=1 + sub(/\s+(${(j:|:)dis_plugins})/, \"\") + sub(/(${(j:|:)dis_plugins})\s+/, \"\") + sub(/\((${(j:|:)dis_plugins})\)/, \"\") + print \$0 + next +} + +# if multi flag is enabled and we find a valid closing parenthesis, +# add new plugins and disable multi flag +multi == 1 && /^[^#]*\)/ { + multi=0 + sub(/\s+(${(j:|:)dis_plugins})/, \"\") + sub(/(${(j:|:)dis_plugins})\s+/, \"\") + sub(/\((${(j:|:)dis_plugins})\)/, \"\") + print \$0 + next +} + +multi == 1 { + sub(/\s+(${(j:|:)dis_plugins})/, \"\") + sub(/(${(j:|:)dis_plugins})\s+/, \"\") + sub(/\((${(j:|:)dis_plugins})\)/, \"\") + print \$0 + next +} + +{ print \$0 } +" + + awk "$awk_script" ~/.zshrc > ~/.zshrc.disabled \ + && mv ~/.zshrc ~/.zshrc.swp \ + && mv ~/.zshrc.disabled ~/.zshrc + + # Exit if the new .zshrc file wasn't created correctly + [[ $? -eq 0 ]] || { + local ret=$? + _omz::log error "error disabling plugins." + return $ret + } + + # Exit if the new .zshrc file has syntax errors + if ! zsh -n ~/.zshrc; then + _omz::log error "broken syntax in ~/.zshrc. Rolling back changes..." + mv ~/.zshrc ~/.zshrc.disabled + mv ~/.zshrc.swp ~/.zshrc + return 1 + fi + + # Restart the zsh session if there were no errors + _omz::log info "" + + # Old zsh versions don't have ZSH_ARGZERO + local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" + # Check whether to run a login shell + [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh" +} + +function _omz::plugin::enable { + if [[ -z "$1" ]]; then + echo >&2 "Usage: omz plugin enable [...]" + return 1 + fi + + # Check that plugin is not in $plugins + local -a add_plugins=() + for plugin in "$@"; do + if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then + _omz::log warn "plugin '$plugin' is already enabled." + continue + fi + add_plugins+=("$plugin") + done + + # Exit if there are no plugins to enable + if [[ ${#add_plugins} -eq 0 ]]; then + return 1 + fi + + # Enable plugins awk script + local awk_script=" +# if plugins=() is in oneline form, substitute ) with new plugins and go to the next line +/^\s*plugins=\([^#]+\).*\$/ { + sub(/\)/, \" $add_plugins&\") + print \$0 + next +} + +# if plugins=() is in multiline form, enable multi flag +/^\s*plugins=\(/ { + multi=1 +} + +# if multi flag is enabled and we find a valid closing parenthesis, +# add new plugins and disable multi flag +multi == 1 && /^[^#]*\)/ { + multi=0 + sub(/\)/, \" $add_plugins&\") + print \$0 + next +} + +{ print \$0 } +" + + awk "$awk_script" ~/.zshrc > ~/.zshrc.disabled \ + && mv ~/.zshrc ~/.zshrc.swp \ + && mv ~/.zshrc.disabled ~/.zshrc + + # Exit if the new .zshrc file wasn't created correctly + [[ $? -eq 0 ]] || { + local ret=$? + _omz::log error "error disabling plugins." + return $ret + } + + # Exit if the new .zshrc file has syntax errors + if ! zsh -n ~/.zshrc; then + _omz::log error "broken syntax in ~/.zshrc. Rolling back changes..." + mv ~/.zshrc ~/.zshrc.disabled + mv ~/.zshrc.swp ~/.zshrc + return 1 + fi + + # Restart the zsh session if there were no errors + + # Old zsh versions don't have ZSH_ARGZERO + local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" + # Check whether to run a login shell + [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh" +} + function _omz::plugin::info { if [[ -z "$1" ]]; then echo >&2 "Usage: omz plugin info " From 708bbe12c5817e380c83d0c49bf684b0fc5d0024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 17 Aug 2021 12:31:37 +0200 Subject: [PATCH 21/59] fix(cli): fix multiple errors in `plugin disable/enable` --- lib/cli.zsh | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index 1289df730..e490149e0 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -230,9 +230,9 @@ function _omz::plugin::disable { local awk_script=" # if plugins=() is in oneline form, substitute disabled plugins and go to next line /^\s*plugins=\([^#]+\).*\$/ { - sub(/\s+(${(j:|:)dis_plugins})/, \"\") # with spaces before - sub(/(${(j:|:)dis_plugins})\s+/, \"\") # with spaces after - sub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin) + gsub(/\s+(${(j:|:)dis_plugins})/, \"\") # with spaces before + gsub(/(${(j:|:)dis_plugins})\s+/, \"\") # with spaces after + gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin) print \$0 next } @@ -240,9 +240,9 @@ function _omz::plugin::disable { # if plugins=() is in multiline form, enable multi flag and disable plugins if they're there /^\s*plugins=\(/ { multi=1 - sub(/\s+(${(j:|:)dis_plugins})/, \"\") - sub(/(${(j:|:)dis_plugins})\s+/, \"\") - sub(/\((${(j:|:)dis_plugins})\)/, \"\") + gsub(/\s+(${(j:|:)dis_plugins})/, \"\") + gsub(/(${(j:|:)dis_plugins})\s+/, \"\") + gsub(/\((${(j:|:)dis_plugins})\)/, \"\") print \$0 next } @@ -251,17 +251,17 @@ function _omz::plugin::disable { # add new plugins and disable multi flag multi == 1 && /^[^#]*\)/ { multi=0 - sub(/\s+(${(j:|:)dis_plugins})/, \"\") - sub(/(${(j:|:)dis_plugins})\s+/, \"\") - sub(/\((${(j:|:)dis_plugins})\)/, \"\") + gsub(/\s+(${(j:|:)dis_plugins})/, \"\") + gsub(/(${(j:|:)dis_plugins})\s+/, \"\") + gsub(/\((${(j:|:)dis_plugins})\)/, \"\") print \$0 next } multi == 1 { - sub(/\s+(${(j:|:)dis_plugins})/, \"\") - sub(/(${(j:|:)dis_plugins})\s+/, \"\") - sub(/\((${(j:|:)dis_plugins})\)/, \"\") + gsub(/\s+(${(j:|:)dis_plugins})/, \"\") + gsub(/(${(j:|:)dis_plugins})\s+/, \"\") + gsub(/\((${(j:|:)dis_plugins})\)/, \"\") print \$0 next } @@ -283,13 +283,13 @@ multi == 1 { # Exit if the new .zshrc file has syntax errors if ! zsh -n ~/.zshrc; then _omz::log error "broken syntax in ~/.zshrc. Rolling back changes..." - mv ~/.zshrc ~/.zshrc.disabled - mv ~/.zshrc.swp ~/.zshrc + command mv -f ~/.zshrc ~/.zshrc.disabled + command mv -f ~/.zshrc.swp ~/.zshrc return 1 fi # Restart the zsh session if there were no errors - _omz::log info "" + _omz::log info "plugins disabled: ${(j:, :)dis_plugins}." # Old zsh versions don't have ZSH_ARGZERO local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" @@ -344,26 +344,27 @@ multi == 1 && /^[^#]*\)/ { { print \$0 } " - awk "$awk_script" ~/.zshrc > ~/.zshrc.disabled \ - && mv ~/.zshrc ~/.zshrc.swp \ - && mv ~/.zshrc.disabled ~/.zshrc + awk "$awk_script" ~/.zshrc > ~/.zshrc.enabled \ + && command mv -f ~/.zshrc ~/.zshrc.swp \ + && command mv -f ~/.zshrc.enabled ~/.zshrc # Exit if the new .zshrc file wasn't created correctly [[ $? -eq 0 ]] || { local ret=$? - _omz::log error "error disabling plugins." + _omz::log error "error enabling plugins." return $ret } # Exit if the new .zshrc file has syntax errors if ! zsh -n ~/.zshrc; then _omz::log error "broken syntax in ~/.zshrc. Rolling back changes..." - mv ~/.zshrc ~/.zshrc.disabled - mv ~/.zshrc.swp ~/.zshrc + command mv -f ~/.zshrc ~/.zshrc.enabled + command mv -f ~/.zshrc.swp ~/.zshrc return 1 fi # Restart the zsh session if there were no errors + _omz::log info "plugins enabled: ${(j:, :)add_plugins}." # Old zsh versions don't have ZSH_ARGZERO local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" From bf888680ea5b7161cf1d06011df33bfbeda8b255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 17 Aug 2021 12:38:48 +0200 Subject: [PATCH 22/59] refactor(cli): extract substitution awk script in `plugin disable` --- lib/cli.zsh | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index e490149e0..a10b0e147 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -226,13 +226,17 @@ function _omz::plugin::disable { return 1 fi + # Remove plugins substitution awk script + local awk_subst_plugins="\ + gsub(/\s+(${(j:|:)dis_plugins})/, \"\") # with spaces before + gsub(/(${(j:|:)dis_plugins})\s+/, \"\") # with spaces after + gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin) +" # Disable plugins awk script local awk_script=" # if plugins=() is in oneline form, substitute disabled plugins and go to next line /^\s*plugins=\([^#]+\).*\$/ { - gsub(/\s+(${(j:|:)dis_plugins})/, \"\") # with spaces before - gsub(/(${(j:|:)dis_plugins})\s+/, \"\") # with spaces after - gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin) + $awk_subst_plugins print \$0 next } @@ -240,29 +244,22 @@ function _omz::plugin::disable { # if plugins=() is in multiline form, enable multi flag and disable plugins if they're there /^\s*plugins=\(/ { multi=1 - gsub(/\s+(${(j:|:)dis_plugins})/, \"\") - gsub(/(${(j:|:)dis_plugins})\s+/, \"\") - gsub(/\((${(j:|:)dis_plugins})\)/, \"\") + $awk_subst_plugins print \$0 next } -# if multi flag is enabled and we find a valid closing parenthesis, -# add new plugins and disable multi flag +# if multi flag is enabled and we find a valid closing parenthesis, remove plugins and disable multi flag multi == 1 && /^[^#]*\)/ { multi=0 - gsub(/\s+(${(j:|:)dis_plugins})/, \"\") - gsub(/(${(j:|:)dis_plugins})\s+/, \"\") - gsub(/\((${(j:|:)dis_plugins})\)/, \"\") + $awk_subst_plugins print \$0 next } -multi == 1 { - gsub(/\s+(${(j:|:)dis_plugins})/, \"\") - gsub(/(${(j:|:)dis_plugins})\s+/, \"\") - gsub(/\((${(j:|:)dis_plugins})\)/, \"\") - print \$0 +multi == 1 && length(\$0) > 0 { + $awk_subst_plugins + if (length(\$0) > 0) print \$0 next } From bc7ce982ddcabdb7a6d446207ef4a0b78920da8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 17 Aug 2021 12:53:09 +0200 Subject: [PATCH 23/59] style(cli): fill rows in column output in theme and plugin `list` commands --- lib/cli.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index a10b0e147..6bdac6cf1 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -405,14 +405,14 @@ function _omz::plugin::list { if (( ${#custom_plugins} )); then print -P "%U%BCustom plugins%b%u:" - print -l ${(q-)custom_plugins} | column + print -l ${(q-)custom_plugins} | column -x fi if (( ${#builtin_plugins} )); then (( ${#custom_plugins} )) && echo # add a line of separation print -P "%U%BBuilt-in plugins%b%u:" - print -l ${(q-)builtin_plugins} | column + print -l ${(q-)builtin_plugins} | column -x fi } @@ -631,14 +631,14 @@ function _omz::theme::list { if (( ${#custom_themes} )); then print -P "%U%BCustom themes%b%u:" - print -l ${(q-)custom_themes} | column + print -l ${(q-)custom_themes} | column -x fi if (( ${#builtin_themes} )); then (( ${#custom_themes} )) && echo # add a line of separation print -P "%U%BBuilt-in themes%b%u:" - print -l ${(q-)builtin_themes} | column + print -l ${(q-)builtin_themes} | column -x fi } From ad1837859bedc5283b69cfcabee6d2ba5e4ee71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 17 Aug 2021 16:35:42 +0200 Subject: [PATCH 24/59] fix(updater): fix reset ANSI escape code for resetting underline format --- tools/upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 38fac3ce0..e9f8bc0f9 100755 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -30,7 +30,7 @@ if [ -t 1 ]; then BOLD=$(printf '\033[1m') DIM=$(printf '\033[2m') UNDER=$(printf '\033[4m') - RESET=$(printf '\033[m') + RESET=$(printf '\033[0m') fi # Update upstream remote to ohmyzsh org From 7a4f4ad91e1f937b36a54703984b958abe9da4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 17 Aug 2021 17:38:31 +0200 Subject: [PATCH 25/59] fix(lib): fix clipboard copy on Termux --- lib/clipboard.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 122145f15..4e3ba0a45 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -76,7 +76,7 @@ function detect-clipboard() { function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; } function clippaste() { win32yank -o; } elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then - function clipcopy() { termux-clipboard-set "${1:-/dev/stdin}"; } + function clipcopy() { termux-clipboard-set < "${1:-/dev/stdin}"; } function clippaste() { termux-clipboard-get; } elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then function clipcopy() { tmux load-buffer "${1:--}"; } From 10f3e0d4d498c68109bafd711d0bae7f6fa44071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 18 Aug 2021 11:43:29 +0200 Subject: [PATCH 26/59] docs(pyenv): document necessity to logout after PATH settings --- plugins/pyenv/pyenv.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 813f64b42..275c12c80 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -30,7 +30,7 @@ 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 <&2 < Date: Wed, 18 Aug 2021 11:47:50 +0200 Subject: [PATCH 27/59] fix(pyenv): fix for checking if pyenv-virtualenv is installed Fixes #8467 --- plugins/pyenv/pyenv.plugin.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 275c12c80..bcf80a6a2 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -46,16 +46,20 @@ 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)" fi fi if [[ $FOUND_PYENV -eq 1 ]]; then + if [[ -z "$PYENV_ROOT" ]]; then + export PYENV_ROOT="$(pyenv root)" + fi + eval "$(pyenv init - --no-rehash zsh)" - if (( ${+commands[pyenv-virtualenv-init]} )); then + if [[ -d "$PYENV_ROOT/plugins/pyenv-virtualenv" ]]; then eval "$(pyenv virtualenv-init - zsh)" fi From 8dedf26294d4236ffe84260d30d686a705b0d2ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 18 Aug 2021 12:50:22 +0200 Subject: [PATCH 28/59] style(cli): print usage messages to stderr --- lib/cli.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index 6bdac6cf1..b49643339 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -150,7 +150,7 @@ function _omz::log { ## User-facing commands function _omz::help { - cat <&2 < [options] Available commands: @@ -171,7 +171,7 @@ function _omz::changelog { if ! command git -C "$ZSH" show-ref --verify refs/heads/$version &>/dev/null && \ ! command git -C "$ZSH" show-ref --verify refs/tags/$version &>/dev/null && \ ! command git -C "$ZSH" rev-parse --verify "${version}^{commit}" &>/dev/null; then - cat <&2 < must be a valid branch, tag or commit. @@ -184,7 +184,7 @@ EOF function _omz::plugin { (( $# > 0 && $+functions[_omz::plugin::$1] )) || { - cat <&2 < [options] Available commands: @@ -468,7 +468,7 @@ function _omz::plugin::load { function _omz::pr { (( $# > 0 && $+functions[_omz::pr::$1] )) || { - cat <&2 < [options] Available commands: @@ -600,7 +600,7 @@ function _omz::pr::test { function _omz::theme { (( $# > 0 && $+functions[_omz::theme::$1] )) || { - cat <&2 < [options] Available commands: From cbb534267aca09fd123635fc39a7d00c0e21a5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 18 Aug 2021 16:57:56 +0200 Subject: [PATCH 29/59] feat(cli): add `theme set` subcommand to change theme in .zshrc Fixes #9087 --- lib/cli.zsh | 98 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 83 insertions(+), 15 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index b49643339..2189e24ca 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -45,9 +45,9 @@ function _omz { 'load:Load plugin(s)' ) _describe 'command' subcmds ;; - pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches') + pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request') _describe 'command' subcmds ;; - theme) subcmds=('use:Load a theme' 'list:List themes') + theme) subcmds=('list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme') _describe 'command' subcmds ;; esac elif (( CURRENT == 4 )); then @@ -68,7 +68,7 @@ function _omz { plugin::info) local -aU plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) _describe 'plugin' plugins ;; - theme::use) + theme::(set|use)) local -aU themes=("$ZSH"/themes/*.zsh-theme(.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)) _describe 'theme' themes ;; esac @@ -266,9 +266,9 @@ multi == 1 && length(\$0) > 0 { { print \$0 } " - awk "$awk_script" ~/.zshrc > ~/.zshrc.disabled \ - && mv ~/.zshrc ~/.zshrc.swp \ - && mv ~/.zshrc.disabled ~/.zshrc + awk "$awk_script" ~/.zshrc > ~/.zshrc.new \ + && command mv -f ~/.zshrc ~/.zshrc.bck \ + && command mv -f ~/.zshrc.new ~/.zshrc # Exit if the new .zshrc file wasn't created correctly [[ $? -eq 0 ]] || { @@ -280,8 +280,8 @@ multi == 1 && length(\$0) > 0 { # Exit if the new .zshrc file has syntax errors if ! zsh -n ~/.zshrc; then _omz::log error "broken syntax in ~/.zshrc. Rolling back changes..." - command mv -f ~/.zshrc ~/.zshrc.disabled - command mv -f ~/.zshrc.swp ~/.zshrc + command mv -f ~/.zshrc ~/.zshrc.new + command mv -f ~/.zshrc.bck ~/.zshrc return 1 fi @@ -341,9 +341,9 @@ multi == 1 && /^[^#]*\)/ { { print \$0 } " - awk "$awk_script" ~/.zshrc > ~/.zshrc.enabled \ - && command mv -f ~/.zshrc ~/.zshrc.swp \ - && command mv -f ~/.zshrc.enabled ~/.zshrc + awk "$awk_script" ~/.zshrc > ~/.zshrc.new \ + && command mv -f ~/.zshrc ~/.zshrc.bck \ + && command mv -f ~/.zshrc.new ~/.zshrc # Exit if the new .zshrc file wasn't created correctly [[ $? -eq 0 ]] || { @@ -355,8 +355,8 @@ multi == 1 && /^[^#]*\)/ { # Exit if the new .zshrc file has syntax errors if ! zsh -n ~/.zshrc; then _omz::log error "broken syntax in ~/.zshrc. Rolling back changes..." - command mv -f ~/.zshrc ~/.zshrc.enabled - command mv -f ~/.zshrc.swp ~/.zshrc + command mv -f ~/.zshrc ~/.zshrc.new + command mv -f ~/.zshrc.bck ~/.zshrc return 1 fi @@ -606,7 +606,8 @@ Usage: omz theme [options] Available commands: list List all available Oh My Zsh themes - use Load an Oh My Zsh theme + set Set a theme in your .zshrc file + use Load a theme EOF return 1 @@ -642,6 +643,73 @@ function _omz::theme::list { fi } +function _omz::theme::set { + if [[ -z "$1" ]]; then + echo >&2 "Usage: omz theme set " + return 1 + fi + + # Check that theme exists + if [[ ! -f "$ZSH_CUSTOM/$1.zsh-theme" ]] \ + && [[ ! -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]] \ + && [[ ! -f "$ZSH/themes/$1.zsh-theme" ]]; then + _omz::log error "%B$1%b theme not found" + return 1 + fi + + # Enable theme in .zshrc + local awk_script=' +!set && /^\s*ZSH_THEME=[^#]+.*$/ { + set=1 + sub(/^\s*ZSH_THEME=[^#]+.*$/, "ZSH_THEME=\"'$1'\" # set by `omz`") + print $0 + next +} + +{ print $0 } + +END { + # If no ZSH_THEME= line was found, return an error + if (!set) exit 1 +} +' + + awk "$awk_script" ~/.zshrc > ~/.zshrc.new \ + || { + # Prepend ZSH_THEME= line to .zshrc if it doesn't exist + cat < ~/.zshrc.new \ + && command mv -f ~/.zshrc ~/.zshrc.bck \ + && command mv -f ~/.zshrc.new ~/.zshrc + + # Exit if the new .zshrc file wasn't created correctly + [[ $? -eq 0 ]] || { + local ret=$? + _omz::log error "error setting theme." + return $ret + } + + # Exit if the new .zshrc file has syntax errors + if ! zsh -n ~/.zshrc; then + _omz::log error "broken syntax in ~/.zshrc. Rolling back changes..." + command mv -f ~/.zshrc ~/.zshrc.new + command mv -f ~/.zshrc.bck ~/.zshrc + return 1 + fi + + # Restart the zsh session if there were no errors + _omz::log info "'$1' theme set correctly." + + # Old zsh versions don't have ZSH_ARGZERO + local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" + # Check whether to run a login shell + [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh" +} + function _omz::theme::use { if [[ -z "$1" ]]; then echo >&2 "Usage: omz theme use " @@ -656,7 +724,7 @@ function _omz::theme::use { elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then source "$ZSH/themes/$1.zsh-theme" else - _omz::log error "theme '$1' not found" + _omz::log error "%B$1%b theme not found" return 1 fi } From 6d5b8484ce7198161d5f617c3db9fd7d3833d48c Mon Sep 17 00:00:00 2001 From: Ilya Bizyaev Date: Fri, 20 Aug 2021 13:25:58 +0300 Subject: [PATCH 30/59] fix(suse): avoid refresh attempts for Zypper queries (#9798) --- plugins/suse/README.md | 10 ++++++++-- plugins/suse/suse.plugin.zsh | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) 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' From e13ff75f38200b03b26f798991b3ecf30e547d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20=C3=96hrn?= Date: Tue, 24 Aug 2021 19:19:29 +0200 Subject: [PATCH 31/59] fix(kubectx): show plain context if not mapped (#10134) --- plugins/kubectx/kubectx.plugin.zsh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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 } From c47ac2d86d1aec3dcc3106c58d3ef0a91aa8cc3c Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Wed, 25 Aug 2021 10:25:26 +0200 Subject: [PATCH 32/59] feat(mlh): let users configure the official MLH theme (#9997) --- themes/mlh.zsh-theme | 51 +++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/themes/mlh.zsh-theme b/themes/mlh.zsh-theme index 33f238ed9..baff3fb63 100644 --- a/themes/mlh.zsh-theme +++ b/themes/mlh.zsh-theme @@ -12,17 +12,40 @@ # # # Feel free to customize! # # # # # # # # # # # # # # # # # # # # # +# To customize symbols (e.g MLH_AT_SYMBOL), simply set them as environment variables +# for example in your ~/.zshrc file, like this: +# MLH_AT_SYMBOL=" at " +# +# Settings *must* be set before sourcing oh-my-zsh.sh the .zshrc file. +# # To easily discover colors and their codes, type `spectrum_ls` in the terminal -# enable or disable particular elements -PRINT_EXIT_CODE=true -PRINT_TIME=true +# right prompt default settings +if [ -z "$MLH_PRINT_EXIT_CODE" ]; then + MLH_PRINT_EXIT_CODE=true +fi -# symbols -AT_SYMBOL=" @ " -IN_SYMBOL=" in " -ON_SYMBOL=" on " -SHELL_SYMBOL="$" +if [ -z "$MLH_PRINT_TIME" ]; then + MLH_PRINT_TIME=false +fi + +# left prompt symbols default settings + +if [ -z "$MLH_AT_SYMBOL" ]; then + MLH_AT_SYMBOL="@" +fi + +if [ -z "$MLH_IN_SYMBOL" ]; then + MLH_IN_SYMBOL=" in " +fi + +if [ -z "$MLH_ON_SYMBOL" ]; then + MLH_ON_SYMBOL=" on " +fi + +if [ -z "$MLH_SHELL_SYMBOL" ]; then + MLH_SHELL_SYMBOL="$ " +fi # colors USER_COLOR="%F{001}" @@ -47,24 +70,28 @@ directory() { # Prints current time current_time() { - if [ "$PRINT_TIME" = true ]; then + if [ "$MLH_PRINT_TIME" = true ]; then echo " $TIME_COLOR%*%f" fi } # Prints exit code of the last executed command exit_code() { - if [ "$PRINT_EXIT_CODE" = true ]; then + if [ "$MLH_PRINT_EXIT_CODE" = true ]; then echo "%(?..%F{001}exit %?)%f" fi } +prompt_end() { + printf "\n$MLH_SHELL_SYMBOL" +} + # Set git_prompt_info text -ZSH_THEME_GIT_PROMPT_PREFIX="${ON_SYMBOL}${BRANCH_COLOR}" +ZSH_THEME_GIT_PROMPT_PREFIX="${MLH_ON_SYMBOL}${BRANCH_COLOR}" ZSH_THEME_GIT_PROMPT_SUFFIX="%f" ZSH_THEME_GIT_PROMPT_DIRTY="" ZSH_THEME_GIT_PROMPT_CLEAN="" # %B and %b make the text bold -PROMPT='%b$(username)$AT_SYMBOL$(device)$IN_SYMBOL$(directory)$(git_prompt_info)%b $SHELL_SYMBOL ' +PROMPT='%b$(username)$MLH_AT_SYMBOL$(device)$MLH_IN_SYMBOL$(directory)$(git_prompt_info)%b$(prompt_end)' RPROMPT="$(exit_code)$(current_time)" From 5a9d9553cd6861d80cc958132ab5af40fe661ac4 Mon Sep 17 00:00:00 2001 From: Simone Gaiarin Date: Thu, 26 Aug 2021 11:42:17 +0200 Subject: [PATCH 33/59] feat(ssh-agent): allow using external helper to ask for passwords (#7631) --- plugins/ssh-agent/README.md | 9 ++ plugins/ssh-agent/ssh-agent.plugin.zsh | 128 ++++++++++++++----------- 2 files changed, 83 insertions(+), 54 deletions(-) diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md index 8765a9c7e..f46e8bf6a 100644 --- a/plugins/ssh-agent/README.md +++ b/plugins/ssh-agent/README.md @@ -55,6 +55,15 @@ ssh-add -K -c -a /run/user/1000/ssh-auth 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..9bc2e8a21 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -1,56 +1,76 @@ typeset _agent_forwarding _ssh_env_cache function _start_agent() { - local lifetime - zstyle -s :omz:plugins:ssh-agent lifetime lifetime + 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 + # 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 } 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 + 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 + # 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 + # 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 + # 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 + # 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} + # 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} } # Get the filename to store/lookup the environment from @@ -60,21 +80,21 @@ _ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST" 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 + # 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 - } + # 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 + } else - _start_agent + _start_agent fi _add_identities From 7692881d2a61a4ba47eeef5d7827c0d2cb896def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 26 Aug 2021 12:14:53 +0200 Subject: [PATCH 34/59] feat(ssh-agent): only start ssh-agent once (#5359) Close #5359 Close #7379 Co-authored-by: Will Andrews Co-authored-by: zhangyc --- plugins/ssh-agent/ssh-agent.plugin.zsh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 9bc2e8a21..acad4e83e 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -1,5 +1,3 @@ -typeset _agent_forwarding _ssh_env_cache - function _start_agent() { local lifetime zstyle -s :omz:plugins:ssh-agent lifetime lifetime @@ -97,7 +95,23 @@ else _start_agent fi -_add_identities +() { + emulate -L zsh + + command mkdir "$ZSH_CACHE_DIR/ssh-agent.lock" 2>/dev/null || return + + trap " + ret=\$? + + command rm -rf '$ZSH_CACHE_DIR/ssh-agent.lock' + unset _agent_forwarding _ssh_env_cache + unfunction _start_agent _add_identities 2>/dev/null + + return \$ret + " EXIT INT QUIT + + _add_identities +} # tidy up after ourselves unset _agent_forwarding _ssh_env_cache From 3f0672ff946a508329e382261e6eb8f837106e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 26 Aug 2021 12:40:16 +0200 Subject: [PATCH 35/59] refactor(ssh-agent): clean up and reorganize code --- plugins/ssh-agent/ssh-agent.plugin.zsh | 47 +++++++++++++------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index acad4e83e..2049145fd 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -1,12 +1,25 @@ +# Get the filename to store/lookup the environment from +ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST" + function _start_agent() { + # 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 's/^echo/#echo/' >! $_ssh_env_cache - chmod 600 $_ssh_env_cache - . $_ssh_env_cache > /dev/null + 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() { @@ -71,26 +84,12 @@ function _add_identities() { ssh-add "${args[@]}" ${^not_loaded} } -# Get the filename to store/lookup the environment from -_ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST" - # test if agent-forwarding is enabled -zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding +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 - } +# 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 fi @@ -104,15 +103,15 @@ fi ret=\$? command rm -rf '$ZSH_CACHE_DIR/ssh-agent.lock' - unset _agent_forwarding _ssh_env_cache + unset agent_forwarding ssh_env_cache unfunction _start_agent _add_identities 2>/dev/null return \$ret " EXIT INT QUIT _add_identities + } -# tidy up after ourselves -unset _agent_forwarding _ssh_env_cache +unset agent_forwarding ssh_env_cache unfunction _start_agent _add_identities From 0c590aba74f28e94f03eb918c07a90cf1a51f525 Mon Sep 17 00:00:00 2001 From: wl2776 Date: Fri, 27 Aug 2021 19:07:19 +0300 Subject: [PATCH 36/59] fix(git): fix `gbda` alias when there are no merged branches (#10005) --- plugins/git/README.md | 2 +- plugins/git/git.plugin.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 522257d2d..48cf87204 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 | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 3cd558692..f0d9aaedc 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -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' From 4a69ee575c9a8ec96fb6378fecae7777c7afba84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 26 Aug 2021 15:52:09 +0200 Subject: [PATCH 37/59] feat(ssh-agent): allow specifying absolute path to `identities` Fixes #9650 --- plugins/ssh-agent/README.md | 9 +++++++++ plugins/ssh-agent/ssh-agent.plugin.zsh | 12 +++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md index f46e8bf6a..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. diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 2049145fd..c2b9546a2 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -23,12 +23,12 @@ function _start_agent() { } function _add_identities() { - local id line sig lines + local id file 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 + if [[ ! -d "$HOME/.ssh" ]]; then return fi @@ -52,10 +52,12 @@ function _add_identities() { # 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)$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") + 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 From a1847dc860b85a0f0d97126ffe4b9b3a5276d1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 19 Aug 2021 17:20:52 +0200 Subject: [PATCH 38/59] style(sudo): apply main style guide indentation --- plugins/sudo/sudo.plugin.zsh | 70 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index f2445a762..f0a01bc1f 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -15,48 +15,48 @@ # ------------------------------------------------------------------------------ __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)" + [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" - # Save beginning space - local WHITESPACE="" - if [[ ${LBUFFER:0:1} = " " ]]; then - WHITESPACE=" " - LBUFFER="${LBUFFER:1}" + # 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 - # 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 [[ -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" + fi - 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" - fi - - # Preserve beginning space - LBUFFER="${WHITESPACE}${LBUFFER}" + # Preserve beginning space + LBUFFER="${WHITESPACE}${LBUFFER}" } zle -N sudo-command-line From 190325049ef93731ab28295dbedf36d44ab33d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 19 Aug 2021 18:20:57 +0200 Subject: [PATCH 39/59] fix(sudo): allow different $EDITOR settings and fix zsh-syntax-highlighting redraw --- plugins/sudo/sudo.plugin.zsh | 64 ++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index f0a01bc1f..e02f88a87 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -25,6 +25,7 @@ __sudo-replace-buffer() { } sudo-command-line() { + # If line is empty, get the last run command from history [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" # Save beginning space @@ -34,29 +35,56 @@ sudo-command-line() { 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 [[ -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" "" + # 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 - LBUFFER="sudo $LBUFFER" + # Check if the typed command is really an alias to $EDITOR + + # 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 + + # 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 From 21b385e7bd522983642b52b51db5d4a210a77717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 2 Sep 2021 12:29:04 +0200 Subject: [PATCH 40/59] fix(frontend-search): fix codepen.io search (#10157) Fixes #10157 --- plugins/frontend-search/frontend-search.plugin.zsh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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:' From 53b54f5faa271ee90ec31fcffb559541c82b9703 Mon Sep 17 00:00:00 2001 From: Vitaly Polonetsky Date: Fri, 3 Sep 2021 02:43:53 -0700 Subject: [PATCH 41/59] feat(git): guess main branch name also from remotes (#10158) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/git/git.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index f0d9aaedc..2985ba024 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 From c08fb77c2fc62ba8df6ad690df0e1d5c9f24c075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 3 Sep 2021 12:44:01 +0200 Subject: [PATCH 42/59] fix(pyenv): properly load pyenv shims and warn of broken configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #10133 Co-authored-by: Chloé “Matcha” --- plugins/pyenv/pyenv.plugin.zsh | 48 +++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index bcf80a6a2..f55701900 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -1,3 +1,22 @@ +pyenv_config_warning() { + local reason="$1" + local pyenv_root="${PYENV_ROOT/#$HOME/\$HOME}" + cat >&2 <&2 < Date: Fri, 3 Sep 2021 12:53:33 +0200 Subject: [PATCH 43/59] feat(pyenv): silence bad config warning with `ZSH_PYENV_QUIET=true` --- plugins/pyenv/README.md | 7 ++++++- plugins/pyenv/pyenv.plugin.zsh | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/pyenv/README.md b/plugins/pyenv/README.md index d063b55b9..810c67998 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,11 @@ 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. + ## 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 f55701900..679fc5e52 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -1,4 +1,6 @@ pyenv_config_warning() { + [[ "$ZSH_PYENV_QUIET" != true ]] || return 0 + local reason="$1" local pyenv_root="${PYENV_ROOT/#$HOME/\$HOME}" cat >&2 < Date: Fri, 3 Sep 2021 12:56:00 +0200 Subject: [PATCH 44/59] feat(pyenv): don't load pyenv-virtualenv with `ZSH_PYENV_VIRTUALENV=false` Closes #9443 Co-authored-by: Pandu POLUAN --- plugins/pyenv/README.md | 3 +++ plugins/pyenv/pyenv.plugin.zsh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/pyenv/README.md b/plugins/pyenv/README.md index 810c67998..b9ee937b7 100644 --- a/plugins/pyenv/README.md +++ b/plugins/pyenv/README.md @@ -15,6 +15,9 @@ plugins=(... pyenv) - `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 679fc5e52..922df8ead 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -78,7 +78,7 @@ if [[ $FOUND_PYENV -eq 1 ]]; then eval "$(pyenv init - --no-rehash zsh)" # If pyenv-virtualenv exists, load it - if [[ -d "$PYENV_ROOT/plugins/pyenv-virtualenv" ]]; then + if [[ -d "$PYENV_ROOT/plugins/pyenv-virtualenv" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then eval "$(pyenv virtualenv-init - zsh)" fi From 19710a2d17d69dc0315465875c4becbf5e4ead38 Mon Sep 17 00:00:00 2001 From: Terry Date: Mon, 6 Sep 2021 18:02:19 +0930 Subject: [PATCH 45/59] fix(pyenv): do not warn if PYENV_ROOT is undefined (#10162) Co-authored-by: Terry Moschou --- plugins/pyenv/pyenv.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 922df8ead..d91b5daa7 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -62,14 +62,14 @@ if [[ $FOUND_PYENV -ne 1 ]]; then fi if [[ $FOUND_PYENV -eq 1 ]]; then - # Setup $PYENV_ROOT if not already set 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)" - pyenv_config_warning 'missing $PYENV_ROOT' fi # Add pyenv shims to $PATH if not already added - if [[ -z "${path[(Re)$PYENV_ROOT/shims]}" ]]; then + if [[ -z "${path[(Re)$(pyenv root)/shims]}" ]]; then eval "$(pyenv init --path)" pyenv_config_warning 'missing pyenv shims in $PATH' fi @@ -78,7 +78,7 @@ if [[ $FOUND_PYENV -eq 1 ]]; then eval "$(pyenv init - --no-rehash zsh)" # If pyenv-virtualenv exists, load it - if [[ -d "$PYENV_ROOT/plugins/pyenv-virtualenv" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then + if [[ -d "$(pyenv root)/plugins/pyenv-virtualenv" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then eval "$(pyenv virtualenv-init - zsh)" fi From a5850d441b2168bbcc17ddcbe03c9b9cdb2720e0 Mon Sep 17 00:00:00 2001 From: Neil Girdhar Date: Mon, 6 Sep 2021 05:21:44 -0400 Subject: [PATCH 46/59] feat(git): change from commiter to author in `git log` aliases (#9670) --- plugins/git/README.md | 6 +++--- plugins/git/git.plugin.zsh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 48cf87204..13571c821 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -98,11 +98,11 @@ 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=\ | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 2985ba024..03769ed0f 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -210,11 +210,11 @@ 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" From a15ac80bba400cffd6a2e2e32be9c39cd7d13411 Mon Sep 17 00:00:00 2001 From: Gijs Key Date: Mon, 6 Sep 2021 11:28:32 +0200 Subject: [PATCH 47/59] feat(gcloud): add Mac M1 Homebrew path (#10143) Homebrew on Mac M1 is moved to the /opt/Homebrew location. This change updates the search locations with this path. --- plugins/gcloud/gcloud.plugin.zsh | 1 + 1 file changed, 1 insertion(+) 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/" From 4d5bfe4c69360353cf7ed9d99b672cb840e9bbcf Mon Sep 17 00:00:00 2001 From: Julian Horsch Date: Mon, 6 Sep 2021 11:30:28 +0200 Subject: [PATCH 48/59] feat(autojump): add new Homebrew default path on M1 Macs (#9637) On M1-Macs homebrew uses /opt/homebrew as default location for ARM packages. This results in the autojump plugin not being able to find autojump after a clean default installation. This commit adds the new default location to the autojump plugin. --- plugins/autojump/autojump.plugin.zsh | 1 + 1 file changed, 1 insertion(+) 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 From 97b4ab76b8c3743187495599a1ca87c520665299 Mon Sep 17 00:00:00 2001 From: "Michael J. Cohen" Date: Mon, 6 Sep 2021 05:31:56 -0400 Subject: [PATCH 49/59] fix(chruby): fix typo in test for Homebrew path (#9887) --- plugins/chruby/chruby.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() { From 7336ebcd8f095b0ead7e1e39bdc2fff57275acfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 6 Sep 2021 13:30:16 +0200 Subject: [PATCH 50/59] feat(changelog): change style of `BREAKING CHANGES` header --- tools/changelog.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/changelog.sh b/tools/changelog.sh index 6913ae49a..b4b8d0c9e 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -285,8 +285,9 @@ function display-release { (( $#breaking != 0 )) || return 0 case "$output" in + text) fmt:header "\e[31mBREAKING CHANGES" 3 ;; raw) fmt:header "BREAKING CHANGES" 3 ;; - text|md) fmt:header "⚠ BREAKING CHANGES" 3 ;; + md) fmt:header "BREAKING CHANGES ⚠" 3 ;; esac local hash subject From 5a4159cd29ab9dfa31e7747dd676f3cf0e19bf81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 6 Sep 2021 13:25:35 +0200 Subject: [PATCH 51/59] fix(git)!: rename `git mergetool` aliases to `gmtl*` (#9154) BREAKING CHANGE: the `gmt` alias conflicts with the Generic Mapping Tools command. For that, the `gmt` alias has been renamed to `gmtl`, and `gmtvim` has been renamed to `gmtlvim` for consistency. Fixes #9154 --- plugins/git/README.md | 4 ++-- plugins/git/git.plugin.zsh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 13571c821..64c507345 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -108,8 +108,8 @@ plugins=(... git) | glp | git log --pretty=\ | | 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 03769ed0f..d030d2801 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -221,8 +221,8 @@ 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' From ab8b9913cb6cba35da3126887d4c0b67f033fffa Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Mon, 6 Sep 2021 23:46:56 +0800 Subject: [PATCH 52/59] fix(git-auto-fetch): cancel fetch if we don't have permission over git folder (#10010) --- plugins/git-auto-fetch/git-auto-fetch.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh index 0da84f2f5..dbc949621 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 From af271c9e387f9b536205a7f459802369cb26a7e0 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Mon, 6 Sep 2021 18:56:39 +0300 Subject: [PATCH 53/59] feat(git-auto-fetch): add date to git-auto-fetch log file (#10021) --- plugins/git-auto-fetch/git-auto-fetch.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh index dbc949621..efe8cbe66 100644 --- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh +++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh @@ -25,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" ) &| } From f341c8c20646bd82d5d84fae32f68b760e0f1be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 7 Sep 2021 17:08:46 +0200 Subject: [PATCH 54/59] feat(changelog): print BREAKING CHANGE messages in a prettier way --- tools/changelog.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tools/changelog.sh b/tools/changelog.sh index b4b8d0c9e..966e91c25 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -181,6 +181,12 @@ function display-release { return fi + # Get length of longest scope for padding + local max_scope=0 + for hash in ${(k)scopes}; do + max_scope=$(( max_scope < ${#scopes[$hash]} ? ${#scopes[$hash]} : max_scope )) + done + ##* Formatting functions # Format the hash according to output format @@ -220,18 +226,13 @@ function display-release { #* Uses $scopes (A) and $hash from outer scope local scope="${1:-${scopes[$hash]}}" - # Get length of longest scope for padding - local max_scope=0 padding=0 - for hash in ${(k)scopes}; do - max_scope=$(( max_scope < ${#scopes[$hash]} ? ${#scopes[$hash]} : max_scope )) - done - # If no scopes, exit the function if [[ $max_scope -eq 0 ]]; then return fi # Get how much padding is required for this scope + local padding=0 padding=$(( max_scope < ${#scope} ? 0 : max_scope - ${#scope} )) padding="${(r:$padding:: :):-}" @@ -290,11 +291,15 @@ function display-release { md) fmt:header "BREAKING CHANGES ⚠" 3 ;; esac - local hash subject + local hash message + local wrap_width=$(( (COLUMNS < 100 ? COLUMNS : 100) - 3 )) for hash message in ${(kv)breaking}; do - echo " - $(fmt:hash) $(fmt:scope)$(fmt:subject "${message}")" - done | sort - echo + # Format the BREAKING CHANGE message by word-wrapping it at maximum 100 characters + # (use $COLUMNS if smaller than 100), and adding a 3-space left padding. + message="$(fmt -w $wrap_width <<< "$message" | sed 's/^/ /')" + # Display hash and scope first, and then the full message with newline separators + echo " - $(fmt:hash) $(fmt:scope)\n\n$(fmt:subject "$message")\n" + done } function display:type { From 37a60eebc107c08047d4b5716c1c1760104aa25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 7 Sep 2021 17:13:46 +0200 Subject: [PATCH 55/59] chore(changelog): fix first-letter uppercase in breaking change messages --- tools/changelog.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/changelog.sh b/tools/changelog.sh index 966e91c25..7329a9526 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -294,11 +294,12 @@ function display-release { local hash message local wrap_width=$(( (COLUMNS < 100 ? COLUMNS : 100) - 3 )) for hash message in ${(kv)breaking}; do - # Format the BREAKING CHANGE message by word-wrapping it at maximum 100 characters - # (use $COLUMNS if smaller than 100), and adding a 3-space left padding. - message="$(fmt -w $wrap_width <<< "$message" | sed 's/^/ /')" - # Display hash and scope first, and then the full message with newline separators - echo " - $(fmt:hash) $(fmt:scope)\n\n$(fmt:subject "$message")\n" + # Format the BREAKING CHANGE message by word-wrapping it at maximum 100 + # characters (use $COLUMNS if smaller than 100) + message="$(fmt -w $wrap_width <<< "$message")" + # Display hash and scope in their own line, and then the full message with + # blank lines as separators and a 3-space left padding + echo " - $(fmt:hash) $(fmt:scope)\n\n$(fmt:subject "$message" | sed 's/^/ /')\n" done } From 450acc0113b114352ce3b94870fe63fc461844bd Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 7 Sep 2021 20:02:20 +0200 Subject: [PATCH 56/59] fix: automatically create completion for `cargo` and `rustup` plugins (#10087) --- plugins/cargo/.gitignore | 1 + plugins/cargo/_cargo | 407 ----------- plugins/cargo/cargo.plugin.zsh | 11 + plugins/rustup/.gitignore | 1 + plugins/rustup/_rustup | 1143 ------------------------------ plugins/rustup/rustup.plugin.zsh | 12 + 6 files changed, 25 insertions(+), 1550 deletions(-) create mode 100644 plugins/cargo/.gitignore delete mode 100644 plugins/cargo/_cargo create mode 100644 plugins/cargo/cargo.plugin.zsh create mode 100644 plugins/rustup/.gitignore delete mode 100644 plugins/rustup/_rustup create mode 100644 plugins/rustup/rustup.plugin.zsh 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/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 From 130f35fcb2e175e28178f834b16e00f121319bc4 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Thu, 9 Sep 2021 19:16:15 +0200 Subject: [PATCH 57/59] feat(git): add `gdu` alias to diff against upstream (#8721) --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 64c507345..e53d93b0b 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -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 | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index d030d2801..76e0faed3 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -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() { From aa6e932b06137a697296ea5be62c73905ff68848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3hann=20Fri=C3=B0riksson?= Date: Thu, 9 Sep 2021 19:31:01 +0200 Subject: [PATCH 58/59] fix(vim-interaction): look up the newest GVim instance (#9095) Instead of relying on a hardcoded instance-name existing for the default-value, let's look up the latest instance. This also resolves my problem where MacVim had a servername of "VIM" instead of "GVIM". Co-authored-by: Johann Fridriksson --- plugins/vim-interaction/vim-interaction.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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="" 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 From 358ac6a141010b19175d0eb5a6f28ff544aa75d3 Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Fri, 10 Sep 2021 04:18:09 +0800 Subject: [PATCH 59/59] fix(cp): add unique suffix to rsync backup directory for each user (#10170) * fix(cp): add unique suffix to rsync backup directory for each user * fix(cp): use `USERNAME` rather than `USER` --- plugins/cp/README.md | 2 +- plugins/cp/cp.plugin.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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