-
-
Save thecodermehedi/cd3df8090c73a80e85612765d1c6cb35 to your computer and use it in GitHub Desktop.
.zshrc with fnm
This file contains hidden or 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 hidden or 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