mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-01 04:30:37 +02:00
nvm plugin: alternate install locations, README, NVM-shipped completion
This commit is contained in:
parent
e391fd94a7
commit
6fd1013b0d
3 changed files with 73 additions and 4 deletions
|
|
@ -1,5 +1,40 @@
|
|||
# Set NVM_DIR if it isn't already defined
|
||||
[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm"
|
||||
# nvm
|
||||
#
|
||||
# This plugin locates and loads nvm, looking for it in well-known locations.
|
||||
|
||||
# Load nvm if it exists
|
||||
[[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
|
||||
() {
|
||||
emulate -L zsh
|
||||
local nvm_dir="" dir install_locations
|
||||
if [[ -n $NVM_DIR ]]; then
|
||||
nvm_dir=$NVM_DIR
|
||||
else
|
||||
# Well-known common installation locations for NVM
|
||||
install_locations=( ~/.nvm )
|
||||
# Mac Homebrew sticks
|
||||
which brew &>/dev/null && install_locations+=$(brew --prefix nvm)
|
||||
for dir ($install_locations); do
|
||||
if [[ -s $dir/nvm.sh ]]; then
|
||||
nvm_dir=$dir
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ -n $nvm_dir ]]; then
|
||||
source $nvm_dir/nvm.sh
|
||||
fi
|
||||
|
||||
# Locate and use the completion file shipped with NVM, instead of this
|
||||
# plugin's completion
|
||||
# (Their bash completion file has zsh portability support)
|
||||
if [[ $ZSH_NVM_BUNDLED_COMPLETION == true ]]; then
|
||||
local bash_comp_file
|
||||
# Homebrew relocates the bash completion file, so look multiple places
|
||||
for bash_comp_file ( bash_completion etc/bash_completion.d/nvm ); do
|
||||
if [[ -s $NVM_DIR/$bash_comp_file ]]; then
|
||||
source $NVM_DIR/$bash_comp_file
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue