summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Childs <lukechilds123@gmail.com>2016-08-07 18:36:44 +0100
committerMarc Cornellà <marc.cornella@live.com>2016-08-07 19:36:44 +0200
commita7de0fabd7ebbf1776942a8c7fde8ee33ed681b0 (patch)
treee9b1da02aeb49d292618d08ae34ccf1ea8d15285
parent7654b16b3963844e5079a8935eb93f108c52f273 (diff)
downloadzsh-a7de0fabd7ebbf1776942a8c7fde8ee33ed681b0.tar.gz
zsh-a7de0fabd7ebbf1776942a8c7fde8ee33ed681b0.tar.bz2
zsh-a7de0fabd7ebbf1776942a8c7fde8ee33ed681b0.zip
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
-rw-r--r--lib/nvm.zsh2
-rw-r--r--plugins/nvm/_nvm2
-rw-r--r--plugins/nvm/nvm.plugin.zsh6
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"