diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2021-09-27 13:03:58 -0600 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2021-09-27 13:03:58 -0600 |
commit | c674485e6b4abe313469900997d893d2940ee843 (patch) | |
tree | d6ca6edaff3d81849489f31ca13b127acef89c75 /plugins/rustup | |
parent | 3c73976ef306d68a85d60c94be9a1dcdc33fa2bf (diff) | |
parent | 93ad3a88214b95f571e03c21f7d9bd76f9110938 (diff) | |
download | zsh-c674485e6b4abe313469900997d893d2940ee843.tar.gz zsh-c674485e6b4abe313469900997d893d2940ee843.tar.bz2 zsh-c674485e6b4abe313469900997d893d2940ee843.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'plugins/rustup')
-rw-r--r-- | plugins/rustup/.gitignore | 1 | ||||
-rw-r--r-- | plugins/rustup/rustup.plugin.zsh | 24 |
2 files changed, 17 insertions, 8 deletions
diff --git a/plugins/rustup/.gitignore b/plugins/rustup/.gitignore deleted file mode 100644 index ad38ae3bf..000000000 --- a/plugins/rustup/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_rustup diff --git a/plugins/rustup/rustup.plugin.zsh b/plugins/rustup/rustup.plugin.zsh index c7a9b3060..c6efc1b13 100644 --- a/plugins/rustup/rustup.plugin.zsh +++ b/plugins/rustup/rustup.plugin.zsh @@ -1,12 +1,22 @@ -# 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 + # remove old generated completion file + command rm -f "${0:A:h}/_rustup" + + ver="$(rustup --version 2>/dev/null)" + ver_file="$ZSH_CACHE_DIR/rustup_version" + 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" + echo "$ver" >| "$ver_file" fi + + declare -A _comps autoload -Uz _rustup _comps[rustup]=_rustup + + unset ver ver_file comp_file fi |