From d2269180b074263f4a0d3df3f9de15a1abae8110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 15 Sep 2021 18:41:44 +0200 Subject: [PATCH] fix(core): move plugin-generated completion files to `$ZSH_CACHE_DIR/completions` Fixes #10183 --- oh-my-zsh.sh | 4 ++++ plugins/cargo/cargo.plugin.zsh | 5 ++++- plugins/deno/deno.plugin.zsh | 5 ++++- plugins/fnm/fnm.plugin.zsh | 5 ++++- plugins/gh/gh.plugin.zsh | 5 ++++- plugins/rustup/rustup.plugin.zsh | 5 ++++- 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 16e244be5..442972a9a 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -7,6 +7,10 @@ if [[ -z "$ZSH_CACHE_DIR" ]]; then ZSH_CACHE_DIR="$ZSH/cache" fi +# Create completions cache dir and add to $fpath +mkdir -p "$ZSH_CACHE_DIR/completions" +(( ${fpath[(Ie)$ZSH_CACHE_DIR/completions]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath) + # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then source $ZSH/tools/check_for_upgrade.sh diff --git a/plugins/cargo/cargo.plugin.zsh b/plugins/cargo/cargo.plugin.zsh index b636d492f..95e63dd3c 100644 --- a/plugins/cargo/cargo.plugin.zsh +++ b/plugins/cargo/cargo.plugin.zsh @@ -1,7 +1,10 @@ if (( $+commands[rustup] && $+commands[cargo] )); then ver="$(cargo --version)" ver_file="$ZSH_CACHE_DIR/cargo_version" - comp_file="$ZSH/plugins/cargo/_cargo" + comp_file="$ZSH_CACHE_DIR/completions/_cargo" + + mkdir -p "${comp_file:h}" + (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath) if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then rustup completions zsh cargo >| "$comp_file" diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh index 71749f4a0..e22c4e4c8 100644 --- a/plugins/deno/deno.plugin.zsh +++ b/plugins/deno/deno.plugin.zsh @@ -14,7 +14,10 @@ alias dup='deno upgrade' if (( $+commands[deno] )); then ver="$(deno --version)" ver_file="$ZSH_CACHE_DIR/deno_version" - comp_file="$ZSH/plugins/deno/_deno" + comp_file="$ZSH_CACHE_DIR/completions/_deno" + + mkdir -p "${comp_file:h}" + (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath) if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then deno completions zsh >| "$comp_file" diff --git a/plugins/fnm/fnm.plugin.zsh b/plugins/fnm/fnm.plugin.zsh index 29b759abb..efb81a6fa 100644 --- a/plugins/fnm/fnm.plugin.zsh +++ b/plugins/fnm/fnm.plugin.zsh @@ -1,7 +1,10 @@ if (( $+commands[fnm] )); then ver="$(fnm --version)" ver_file="$ZSH_CACHE_DIR/fnm_version" - comp_file="$ZSH/plugins/fnm/_fnm" + comp_file="$ZSH_CACHE_DIR/completions/_fnm" + + mkdir -p "${comp_file:h}" + (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath) if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then fnm completions --shell=zsh >| "$comp_file" diff --git a/plugins/gh/gh.plugin.zsh b/plugins/gh/gh.plugin.zsh index c3d87848d..a346ccf65 100644 --- a/plugins/gh/gh.plugin.zsh +++ b/plugins/gh/gh.plugin.zsh @@ -2,7 +2,10 @@ if (( $+commands[gh] )); then ver="$(gh --version)" ver_file="$ZSH_CACHE_DIR/gh_version" - comp_file="$ZSH/plugins/gh/_gh" + comp_file="$ZSH_CACHE_DIR/completions/_gh" + + mkdir -p "${comp_file:h}" + (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath) if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then gh completion --shell zsh >| "$comp_file" diff --git a/plugins/rustup/rustup.plugin.zsh b/plugins/rustup/rustup.plugin.zsh index e709f41bd..8740f255a 100644 --- a/plugins/rustup/rustup.plugin.zsh +++ b/plugins/rustup/rustup.plugin.zsh @@ -1,7 +1,10 @@ if (( $+commands[rustup] )); then ver="$(rustup --version 2>/dev/null)" ver_file="$ZSH_CACHE_DIR/rustup_version" - comp_file="$ZSH/plugins/rustup/_rustup" + comp_file="$ZSH_CACHE_DIR/completions/_rustup" + + mkdir -p "${comp_file:h}" + (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath) if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then rustup completions zsh >| "$comp_file"