From d9ad99531f74df8b0d6622feeab5e253528b43d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20=C5=A0ebenik?= Date: Fri, 23 Jul 2021 12:39:51 +0200 Subject: [PATCH] feat(plugins): add fnm plugin (#9864) Co-authored-by: Ziga Sebenik --- plugins/fnm/.gitignore | 2 ++ plugins/fnm/README.md | 9 +++++++++ plugins/fnm/fnm.plugin.zsh | 12 ++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 plugins/fnm/.gitignore create mode 100644 plugins/fnm/README.md create mode 100644 plugins/fnm/fnm.plugin.zsh diff --git a/plugins/fnm/.gitignore b/plugins/fnm/.gitignore new file mode 100644 index 000000000..0b2bc9ab7 --- /dev/null +++ b/plugins/fnm/.gitignore @@ -0,0 +1,2 @@ +_fnm + diff --git a/plugins/fnm/README.md b/plugins/fnm/README.md new file mode 100644 index 000000000..00fab5cd4 --- /dev/null +++ b/plugins/fnm/README.md @@ -0,0 +1,9 @@ +# fnm plugin + +This plugin adds autocompletion for [fnm](https://github.com/Schniz/fnm) - a Node.js version manager. + +To use it, add `fnm` to the plugins array in your zshrc file: + +```zsh +plugins=(... fnm) +``` diff --git a/plugins/fnm/fnm.plugin.zsh b/plugins/fnm/fnm.plugin.zsh new file mode 100644 index 000000000..5ce558dcb --- /dev/null +++ b/plugins/fnm/fnm.plugin.zsh @@ -0,0 +1,12 @@ +# COMPLETION FUNCTION +if (( $+commands[fnm] )); then + if [[ ! -f $ZSH_CACHE_DIR/fnm_version ]] \ + || [[ "$(fnm --version)" != "$(< "$ZSH_CACHE_DIR/fnm_version")" ]] \ + || [[ ! -f $ZSH/plugins/fnm/_fnm ]]; then + fnm completions --shell=zsh > $ZSH/plugins/fnm/_fnm + fnm --version > $ZSH_CACHE_DIR/fnm_version + fi + autoload -Uz _fnm + _comps[fnm]=_fnm +fi +