rustup.plugin.zsh 615 B

12345678910111213141516171819202122
  1. if (( $+commands[rustup] )); then
  2. # remove old generated completion file
  3. command rm -f "${0:A:h}/_rustup"
  4. ver="$(rustup --version 2>/dev/null)"
  5. ver_file="$ZSH_CACHE_DIR/rustup_version"
  6. comp_file="$ZSH_CACHE_DIR/completions/_rustup"
  7. mkdir -p "${comp_file:h}"
  8. (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
  9. if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
  10. rustup completions zsh >| "$comp_file"
  11. echo "$ver" >| "$ver_file"
  12. fi
  13. declare -A _comps
  14. autoload -Uz _rustup
  15. _comps[rustup]=_rustup
  16. unset ver ver_file comp_file
  17. fi