2021-07-23 12:39:51 +02:00
|
|
|
if (( $+commands[fnm] )); then
|
2021-12-18 21:53:49 +01:00
|
|
|
# Handle $0 according to the standard:
|
2021-12-28 14:16:54 +01:00
|
|
|
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
2021-12-18 21:53:49 +01:00
|
|
|
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
|
|
|
0="${${(M)0:#/*}:-$PWD/$0}"
|
|
|
|
|
2021-09-15 18:47:51 +02:00
|
|
|
# remove old generated completion file
|
|
|
|
command rm -f "${0:A:h}/_fnm"
|
|
|
|
|
2021-09-15 18:18:25 +02:00
|
|
|
ver="$(fnm --version)"
|
|
|
|
ver_file="$ZSH_CACHE_DIR/fnm_version"
|
2021-09-15 18:41:44 +02:00
|
|
|
comp_file="$ZSH_CACHE_DIR/completions/_fnm"
|
|
|
|
|
|
|
|
mkdir -p "${comp_file:h}"
|
|
|
|
(( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
|
2021-09-15 18:18:25 +02:00
|
|
|
|
|
|
|
if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
|
|
|
|
fnm completions --shell=zsh >| "$comp_file"
|
|
|
|
echo "$ver" >| "$ver_file"
|
2021-07-23 12:39:51 +02:00
|
|
|
fi
|
2021-09-15 18:18:25 +02:00
|
|
|
|
|
|
|
declare -A _comps
|
2021-07-23 12:39:51 +02:00
|
|
|
autoload -Uz _fnm
|
|
|
|
_comps[fnm]=_fnm
|
2021-09-15 18:18:25 +02:00
|
|
|
|
|
|
|
unset ver ver_file comp_file
|
2021-07-23 12:39:51 +02:00
|
|
|
fi
|
|
|
|
|