various additions from sim laptop
This commit is contained in:
parent
912a3282c5
commit
21e41141ef
13 changed files with 645 additions and 28 deletions
33
plugins/nvm/nvm.plugin.zsh
Normal file
33
plugins/nvm/nvm.plugin.zsh
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
typeset -a chpwd_functions __chromaz_extra_left
|
||||
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
nvm() {
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
nvm "$@"
|
||||
}
|
||||
_prompt_nvm_version() {
|
||||
[[ -z $NVM_BIN ]] && return
|
||||
echo "nvm: ${NVM_BIN:h:t}"
|
||||
}
|
||||
__chromaz_extra_left+=_prompt_nvm_version
|
||||
|
||||
find-nvmrc-version() {
|
||||
local dir=${1:-${PWD:a}}
|
||||
if [[ $dir == / ]]; then return 1; fi
|
||||
if [[ -e $dir/.nvmrc ]]; then
|
||||
< $dir/.nvmrc
|
||||
else
|
||||
find-nvmrc-version ${dir:h}
|
||||
fi
|
||||
}
|
||||
|
||||
chpwd-set-nvm() {
|
||||
if vers=$(find-nvmrc-version); then
|
||||
if [[ $vers != ${NVM_BIN:h:t} ]]; then
|
||||
nvm use
|
||||
fi
|
||||
fi
|
||||
}
|
||||
chpwd-set-nvm &>/dev/null
|
||||
|
||||
chpwd_functions+=chpwd-set-nvm
|
||||
Loading…
Add table
Add a link
Reference in a new issue