Created
April 14, 2021 02:27
-
-
Save unyo/5b2399c4eb42b8423f99865e65fa020f to your computer and use it in GitHub Desktop.
.zshrc with fnm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fnm | |
eval "$(fnm env)" | |
# add fnm autocomplete | |
fnm completions --shell=zsh > ~/.config/zsh/completions/_fnm # you can run this once and then comment out | |
fpath+=~/.config/zsh/completions/_fnm | |
autoload -U compinit | |
compinit | |
# autoload .nvmrc | |
source ~/auto-node-version-switch.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/rockaBe/ad1e2556f84c7b8807acdd2e09063ee0 | |
# ZSH | |
autoload -U add-zsh-hook | |
# place default node version under $HOME/.node-version | |
load-nvmrc() { | |
DEFAULT_NODE_VERSION=`cat $HOME/.node-version` | |
if [[ -f .nvmrc && -r .nvmrc ]] || [[ -f .node-version && -r .node-version ]]; then | |
fnm use | |
elif | |
[[ `node -v` != $DEFAULT_NODE_VERSION ]]; then | |
echo Reverting to node from "`node -v`" to "$DEFAULT_NODE_VERSION" | |
fnm use $DEFAULT_NODE_VERSION | |
fi | |
} | |
add-zsh-hook chpwd load-nvmrc | |
load-nvmrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
brew install fnm