update fnm env

This commit is contained in:
xfy
2024-12-06 17:09:21 +08:00
parent 10a104b5a9
commit ede8d15169

View File

@ -24,16 +24,10 @@ fi
export EDITOR="nvim"
# node
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
if command -v fnm >/dev/null 2>&1; then
eval "$(fnm env --use-on-cd --shell zsh)"
else
export NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
if [[ $OSTYPE == "linux"* ]]; 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
fi
if [[ $OSTYPE == "darwin"* ]]; then
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
fi
# rust
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
@ -129,28 +123,6 @@ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local nvmrc_path
nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
nvm use
fi
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
if [[ $OSTYPE == "darwin"* ]]; then
# Add deno completions to search path
if [[ ":$FPATH:" != *":/Users/xfy/.zsh/completions:"* ]]; then export FPATH="/Users/xfy/.zsh/completions:$FPATH"; fi
@ -163,4 +135,3 @@ if [[ $OSTYPE == "linux"* ]]; then
export WASMER_DIR="/home/xfy/.wasmer"
[ -s "$WASMER_DIR/wasmer.sh" ] && source "$WASMER_DIR/wasmer.sh"
fi