-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.zshrc.local.disabled
55 lines (45 loc) · 1.56 KB
/
.zshrc.local.disabled
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# some stuff I don't want to delete
#per OS
if [[ -r /etc/debian_version ]] ; then
# nvm
if [ -d "$HOME/.nvm" ]; then
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# https://tecadmin.net/install-nvm-macos-with-homebrew/
if [ -d "$HOME/.nvm" ]; then
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
[ -s "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" ] && \. "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
fi
fi
# ruby env, first needed for jekyll development
if which rbenv >/dev/null; then
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
fi
# found https://stackoverflow.com/a/57839539
# place this after nvm initialization!
# add auto switch node version if nvm is initialized
if which nvm >/dev/null; then
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc
fi