From 2d32e9be668672c110405aa2952ab8adaf374856 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sat, 18 Dec 2021 14:53:49 -0600 Subject: refactor: handle `$0` according to the Zsh plugin standard (#10518) For details and rationale, see: https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html Closes #10518 --- plugins/deno/deno.plugin.zsh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plugins/deno/deno.plugin.zsh') diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh index eb7191971..88df55af7 100644 --- a/plugins/deno/deno.plugin.zsh +++ b/plugins/deno/deno.plugin.zsh @@ -13,6 +13,11 @@ alias dup='deno upgrade' # COMPLETION FUNCTION if (( $+commands[deno] )); then + # Handle $0 according to the standard: + # # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html + 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" + 0="${${(M)0:#/*}:-$PWD/$0}" + # remove old generated completion file command rm -f "${0:A:h}/_deno" -- cgit v1.2.3-70-g09d2 From c06197ad954baf3567d8711e43ad542aef86e6bc Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 28 Dec 2021 14:16:54 +0100 Subject: chore: fix comment bulk replace --- plugins/cargo/cargo.plugin.zsh | 2 +- plugins/colemak/colemak.plugin.zsh | 2 +- plugins/colored-man-pages/colored-man-pages.plugin.zsh | 2 +- plugins/deno/deno.plugin.zsh | 2 +- plugins/emacs/emacs.plugin.zsh | 2 +- plugins/emoji/emoji.plugin.zsh | 2 +- plugins/emotty/emotty.plugin.zsh | 2 +- plugins/fnm/fnm.plugin.zsh | 2 +- plugins/git-prompt/git-prompt.plugin.zsh | 2 +- plugins/gitfast/gitfast.plugin.zsh | 2 +- plugins/history-substring-search/history-substring-search.plugin.zsh | 2 +- plugins/hitchhiker/hitchhiker.plugin.zsh | 2 +- plugins/macos/macos.plugin.zsh | 2 +- plugins/rustup/rustup.plugin.zsh | 2 +- plugins/tmux/tmux.plugin.zsh | 2 +- plugins/wd/wd.plugin.zsh | 2 +- plugins/z/z.plugin.zsh | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) (limited to 'plugins/deno/deno.plugin.zsh') diff --git a/plugins/cargo/cargo.plugin.zsh b/plugins/cargo/cargo.plugin.zsh index 20aeb6652..6651f6432 100644 --- a/plugins/cargo/cargo.plugin.zsh +++ b/plugins/cargo/cargo.plugin.zsh @@ -3,7 +3,7 @@ print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f' # TODO: 2021-12-28: remove this block # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" # Remove old generated completion file diff --git a/plugins/colemak/colemak.plugin.zsh b/plugins/colemak/colemak.plugin.zsh index de0b5b866..e6a46f296 100644 --- a/plugins/colemak/colemak.plugin.zsh +++ b/plugins/colemak/colemak.plugin.zsh @@ -20,7 +20,7 @@ bindkey -a 'j' vi-forward-word-end bindkey -a 'J' vi-forward-blank-word-end # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh index 040e74fc9..087ddce97 100644 --- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh +++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh @@ -17,7 +17,7 @@ less_termcap[us]="${fg_bold[green]}" less_termcap[ue]="${reset_color}" # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh index 88df55af7..15fe15a7b 100644 --- a/plugins/deno/deno.plugin.zsh +++ b/plugins/deno/deno.plugin.zsh @@ -14,7 +14,7 @@ alias dup='deno upgrade' # COMPLETION FUNCTION if (( $+commands[deno] )); then # Handle $0 according to the standard: - # # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html + # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index 258e57f24..fede5b0c4 100644 --- a/plugins/emacs/emacs.plugin.zsh +++ b/plugins/emacs/emacs.plugin.zsh @@ -14,7 +14,7 @@ autoload -Uz is-at-least is-at-least 24 "${${(Az)"$(emacsclient --version 2>/dev/null)"}[2]}" || return 0 # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh index 60d00d976..876011957 100644 --- a/plugins/emoji/emoji.plugin.zsh +++ b/plugins/emoji/emoji.plugin.zsh @@ -5,7 +5,7 @@ # See the README for documentation. # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/emotty/emotty.plugin.zsh b/plugins/emotty/emotty.plugin.zsh index 959390a31..661169a8b 100644 --- a/plugins/emotty/emotty.plugin.zsh +++ b/plugins/emotty/emotty.plugin.zsh @@ -11,7 +11,7 @@ # ------------------------------------------------------------------------------ # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/fnm/fnm.plugin.zsh b/plugins/fnm/fnm.plugin.zsh index a5b0d0900..73e2b958a 100644 --- a/plugins/fnm/fnm.plugin.zsh +++ b/plugins/fnm/fnm.plugin.zsh @@ -1,6 +1,6 @@ if (( $+commands[fnm] )); then # Handle $0 according to the standard: - # # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html + # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index 122542e65..c86c1f59b 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -1,5 +1,5 @@ # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/gitfast/gitfast.plugin.zsh b/plugins/gitfast/gitfast.plugin.zsh index f28e3808c..a6db0c6bd 100644 --- a/plugins/gitfast/gitfast.plugin.zsh +++ b/plugins/gitfast/gitfast.plugin.zsh @@ -1,5 +1,5 @@ # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/history-substring-search/history-substring-search.plugin.zsh b/plugins/history-substring-search/history-substring-search.plugin.zsh index bac2c3ab9..63f0bdd42 100644 --- a/plugins/history-substring-search/history-substring-search.plugin.zsh +++ b/plugins/history-substring-search/history-substring-search.plugin.zsh @@ -1,5 +1,5 @@ # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/hitchhiker/hitchhiker.plugin.zsh b/plugins/hitchhiker/hitchhiker.plugin.zsh index 6d0e40052..0b1a30119 100644 --- a/plugins/hitchhiker/hitchhiker.plugin.zsh +++ b/plugins/hitchhiker/hitchhiker.plugin.zsh @@ -1,5 +1,5 @@ # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh index 144c17ab2..b540eecb5 100644 --- a/plugins/macos/macos.plugin.zsh +++ b/plugins/macos/macos.plugin.zsh @@ -1,5 +1,5 @@ # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/rustup/rustup.plugin.zsh b/plugins/rustup/rustup.plugin.zsh index 698c081e5..d8225901b 100644 --- a/plugins/rustup/rustup.plugin.zsh +++ b/plugins/rustup/rustup.plugin.zsh @@ -3,7 +3,7 @@ print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f' # TODO: 2021-12-28: remove this block # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" # Remove old generated completion file diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 648d12bbf..5474c3522 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -47,7 +47,7 @@ else fi # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/wd/wd.plugin.zsh b/plugins/wd/wd.plugin.zsh index 222a1483a..ca2ca7c65 100644 --- a/plugins/wd/wd.plugin.zsh +++ b/plugins/wd/wd.plugin.zsh @@ -8,7 +8,7 @@ # @github.com/mfaerevaag/wd # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" diff --git a/plugins/z/z.plugin.zsh b/plugins/z/z.plugin.zsh index 7ce13afa7..7d3eacac0 100644 --- a/plugins/z/z.plugin.zsh +++ b/plugins/z/z.plugin.zsh @@ -1,5 +1,5 @@ # Handle $0 according to the standard: -# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" -- cgit v1.2.3-70-g09d2 From 49bae43f6202e7e1171d8911d8b243714dfe888a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 28 Dec 2021 14:30:13 +0100 Subject: refactor(plugins): generate completion functions in the background --- plugins/cargo/cargo.plugin.zsh | 2 +- plugins/deno/deno.plugin.zsh | 39 +++++++++++++++++++-------------------- plugins/fnm/fnm.plugin.zsh | 38 ++++++++++++++++++-------------------- plugins/gh/gh.plugin.zsh | 38 ++++++++++++++++++-------------------- plugins/rustup/rustup.plugin.zsh | 2 +- 5 files changed, 57 insertions(+), 62 deletions(-) (limited to 'plugins/deno/deno.plugin.zsh') diff --git a/plugins/cargo/cargo.plugin.zsh b/plugins/cargo/cargo.plugin.zsh index 6651f6432..e4b338207 100644 --- a/plugins/cargo/cargo.plugin.zsh +++ b/plugins/cargo/cargo.plugin.zsh @@ -7,7 +7,7 @@ print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f' 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" # Remove old generated completion file -command rm -f "${0:A:h}/_cargo" +command rm -f "${0:A:h}/_cargo" "$ZSH_CACHE_DIR/cargo_version" (( ${fpath[(Ie)$ZSH/plugins/rust]} )) || { fpath=("$ZSH/plugins/rust" $fpath) diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh index 15fe15a7b..77c2125d2 100644 --- a/plugins/deno/deno.plugin.zsh +++ b/plugins/deno/deno.plugin.zsh @@ -12,30 +12,29 @@ alias dts='deno test' alias dup='deno upgrade' # COMPLETION FUNCTION -if (( $+commands[deno] )); then - # Handle $0 according to the standard: - # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html - 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" - 0="${${(M)0:#/*}:-$PWD/$0}" - - # remove old generated completion file - command rm -f "${0:A:h}/_deno" - - ver="$(deno --version)" - ver_file="$ZSH_CACHE_DIR/deno_version" - comp_file="$ZSH_CACHE_DIR/completions/_deno" +if (( ! $+commands[deno] )); then + return +fi - mkdir -p "${comp_file:h}" - (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath) +# TODO: 2021-12-28: remove this block +# Handle $0 according to the standard: +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" +0="${${(M)0:#/*}:-$PWD/$0}" +# Remove old generated files +command rm -f "${0:A:h}/_deno" "$ZSH_CACHE_DIR/deno_version" - if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then - deno completions zsh >| "$comp_file" - echo "$ver" >| "$ver_file" - fi +# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh +# Add completions folder in $ZSH_CACHE_DIR +command mkdir -p "$ZSH_CACHE_DIR/completions" +(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath) +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `deno`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_deno" ]]; then declare -A _comps autoload -Uz _deno _comps[deno]=_deno - - unset ver ver_file comp_file fi + +deno completions zsh >| "$ZSH_CACHE_DIR/completions/_deno" &| diff --git a/plugins/fnm/fnm.plugin.zsh b/plugins/fnm/fnm.plugin.zsh index 73e2b958a..e22588792 100644 --- a/plugins/fnm/fnm.plugin.zsh +++ b/plugins/fnm/fnm.plugin.zsh @@ -1,28 +1,26 @@ -if (( $+commands[fnm] )); then - # Handle $0 according to the standard: - # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html - 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" - 0="${${(M)0:#/*}:-$PWD/$0}" - - # remove old generated completion file - command rm -f "${0:A:h}/_fnm" - - ver="$(fnm --version)" - ver_file="$ZSH_CACHE_DIR/fnm_version" - comp_file="$ZSH_CACHE_DIR/completions/_fnm" +if (( ! $+commands[fnm] )); then + return +fi - mkdir -p "${comp_file:h}" - (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath) +# TODO: 2021-12-28: remove this block +# Handle $0 according to the standard: +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" +0="${${(M)0:#/*}:-$PWD/$0}" +# remove old generated files +command rm -f "${0:A:h}/_fnm" "$ZSH_CACHE_DIR/fnm_version" - if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then - fnm completions --shell=zsh >| "$comp_file" - echo "$ver" >| "$ver_file" - fi +# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh +# Add completions folder in $ZSH_CACHE_DIR +command mkdir -p "$ZSH_CACHE_DIR/completions" +(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath) +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `fnm`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then declare -A _comps autoload -Uz _fnm _comps[fnm]=_fnm - - unset ver ver_file comp_file fi +fnm completions --shell=zsh >| "$ZSH_CACHE_DIR/completions/_fnm" &| diff --git a/plugins/gh/gh.plugin.zsh b/plugins/gh/gh.plugin.zsh index 3092bfa4a..17995e1cf 100644 --- a/plugins/gh/gh.plugin.zsh +++ b/plugins/gh/gh.plugin.zsh @@ -1,29 +1,27 @@ # Autocompletion for the GitHub CLI (gh). -if (( $+commands[gh] )); then - # Handle $0 according to the standard: - # # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html - 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" - 0="${${(M)0:#/*}:-$PWD/$0}" - - # remove old generated completion file - command rm -f "${0:A:h}/_gh" - - ver="$(gh --version)" - ver_file="$ZSH_CACHE_DIR/gh_version" - comp_file="$ZSH_CACHE_DIR/completions/_gh" +if (( ! $+commands[gh] )); then + return +fi - mkdir -p "${comp_file:h}" - (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath) +# TODO: 2021-12-28: remove this block +# Handle $0 according to the standard: +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" +0="${${(M)0:#/*}:-$PWD/$0}" +# Remove old generated files +command rm -f "${0:A:h}/_gh" "$ZSH_CACHE_DIR/gh_version" - if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then - gh completion --shell zsh >| "$comp_file" - echo "$ver" >| "$ver_file" - fi +# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh +# Add completions folder in $ZSH_CACHE_DIR +command mkdir -p "$ZSH_CACHE_DIR/completions" +(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath) +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `gh`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_gh" ]]; then declare -A _comps autoload -Uz _gh _comps[gh]=_gh - - unset ver ver_file comp_file fi +gh completion --shell zsh >| "$ZSH_CACHE_DIR/completions/_gh" &| diff --git a/plugins/rustup/rustup.plugin.zsh b/plugins/rustup/rustup.plugin.zsh index d8225901b..3d59c1c54 100644 --- a/plugins/rustup/rustup.plugin.zsh +++ b/plugins/rustup/rustup.plugin.zsh @@ -7,7 +7,7 @@ print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f' 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" # Remove old generated completion file -command rm -f "${0:A:h}/_rustup" +command rm -f "${0:A:h}/_rustup" "$ZSH_CACHE_DIR/rustup_version" (( ${fpath[(Ie)$ZSH/plugins/rust]} )) || { fpath=("$ZSH/plugins/rust" $fpath) -- cgit v1.2.3-70-g09d2