From 59e7ac22451295251b1179a27df8d860b8a0c4a6 Mon Sep 17 00:00:00 2001 From: Vyacheslav Shcherbinin Date: Tue, 17 Oct 2023 13:26:51 +0700 Subject: [PATCH] Added autocompletion for nvm --- README.md | 7 +++++++ _nvm | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 _nvm diff --git a/README.md b/README.md index c60039c..c15f80a 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,13 @@ Then source it in your `.zshrc` (or `.bashrc`) source ~/.zsh-nvm/zsh-nvm.plugin.zsh ``` +#### Add zsh completion +Add the `~/.zsh-nvm` directory to $fpath by adding a line like this to your `.zshrc` file + +```shell +fpath=(~/.zsh-nvm $fpath) +`` + ## Tests To run the tests you'll need to install [Urchin](https://github.com/tlevine/urchin#install). You'll also need to run the tests in an environment that doesn't already have `node` or `nvm` loaded. diff --git a/_nvm b/_nvm new file mode 100644 index 0000000..b037901 --- /dev/null +++ b/_nvm @@ -0,0 +1,33 @@ +#compdef nvm +#autoload + +[[ -f "$NVM_DIR/nvm.sh" ]] || return 0 + +local -a _1st_arguments +_1st_arguments=( + 'help:show help' + '--version:print out the latest released version of nvm' + 'install:download and install a version in ' + 'uninstall:uninstall a version' + 'use:modify PATH to use . Uses .nvmrc if available' + 'exec:run on . Uses .nvmrc if available' + 'run:run `node` on with as arguments. Uses .nvmrc if available' + 'current:list installed versions' + 'ls:list installed versions or versions matching a given description' + 'version:resolve the given description to a single local version' + 'version-remote:resolve the given description to a single remote version' + 'ls-remote:list remote versions available for install' + 'deactivate:undo effects of `nvm` on current shell' + 'alias:show or set aliases' + 'unalias:deletes an alias' + 'reinstall-packages:reinstall global `npm` packages contained in to current version' + 'unload:unload `nvm` from shell' + 'which:display path to installed node version. Uses .nvmrc if available' +) + +_arguments -C '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "nvm subcommand" _1st_arguments + return +fi \ No newline at end of file