fnm.plugin.zsh 955 B

1234567891011121314151617181920212223242526
  1. if (( ! $+commands[fnm] )); then
  2. return
  3. fi
  4. # TODO: 2021-12-28: remove this block
  5. # Handle $0 according to the standard:
  6. # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
  7. 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
  8. 0="${${(M)0:#/*}:-$PWD/$0}"
  9. # remove old generated files
  10. command rm -f "${0:A:h}/_fnm" "$ZSH_CACHE_DIR/fnm_version"
  11. # TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
  12. # Add completions folder in $ZSH_CACHE_DIR
  13. command mkdir -p "$ZSH_CACHE_DIR/completions"
  14. (( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
  15. # If the completion file doesn't exist yet, we need to autoload it and
  16. # bind it to `fnm`. Otherwise, compinit will have already done that.
  17. if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then
  18. declare -A _comps
  19. autoload -Uz _fnm
  20. _comps[fnm]=_fnm
  21. fi
  22. fnm completions --shell=zsh >| "$ZSH_CACHE_DIR/completions/_fnm" &|