From a7de0fabd7ebbf1776942a8c7fde8ee33ed681b0 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Sun, 7 Aug 2016 18:36:44 +0100 Subject: [PATCH] nvm plugin improvements (#5265) * Export $NVM_DIR if it doesn't exist and use it when looking for nvm * Use $NVM_DIR when looking for nvm for completion * Use $NVM_DIR when looking for nvm in nvm_prompt_info --- lib/nvm.zsh | 2 +- plugins/nvm/_nvm | 2 +- plugins/nvm/nvm.plugin.zsh | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/nvm.zsh b/lib/nvm.zsh index 61d997fc0..4a8b6811e 100644 --- a/lib/nvm.zsh +++ b/lib/nvm.zsh @@ -1,6 +1,6 @@ # get the node.js version function nvm_prompt_info() { - [ -f "$HOME/.nvm/nvm.sh" ] || return + [[ -f "$NVM_DIR/nvm.sh" ]] || return local nvm_prompt nvm_prompt=$(node -v 2>/dev/null) [[ "${nvm_prompt}x" == "x" ]] && return diff --git a/plugins/nvm/_nvm b/plugins/nvm/_nvm index a95c9e375..1414dcbb1 100644 --- a/plugins/nvm/_nvm +++ b/plugins/nvm/_nvm @@ -1,7 +1,7 @@ #compdef nvm #autoload -[[ -s ~/.nvm/nvm.sh ]] || return 0 +[[ -f "$NVM_DIR/nvm.sh" ]] || return 0 local -a _1st_arguments _1st_arguments=( diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 9709719fe..9dde3a266 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -1,3 +1,5 @@ -# The addition 'nvm install' attempts in ~/.profile +# Set NVM_DIR if it isn't already defined +[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm" -[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh +# Load nvm if it exists +[[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"