fnm.plugin.zsh 585 B

1234567891011121314151617181920212223
  1. if (( $+commands[fnm] )); then
  2. # remove old generated completion file
  3. command rm -f "${0:A:h}/_fnm"
  4. ver="$(fnm --version)"
  5. ver_file="$ZSH_CACHE_DIR/fnm_version"
  6. comp_file="$ZSH_CACHE_DIR/completions/_fnm"
  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. fnm completions --shell=zsh >| "$comp_file"
  11. echo "$ver" >| "$ver_file"
  12. fi
  13. declare -A _comps
  14. autoload -Uz _fnm
  15. _comps[fnm]=_fnm
  16. unset ver ver_file comp_file
  17. fi