This commit is contained in:
Frank Qing
2025-06-06 14:46:18 +08:00
parent f12bbb6ac1
commit 847ec3b650
2 changed files with 5 additions and 38 deletions

View File

@@ -1,31 +1,8 @@
# fnm (Fast Node Manager) configuration
# https://github.com/Schniz/fnm
# Check if fnm is installed
if command -v fnm &> /dev/null; then
# Set fnm environment variables and enable auto-switching on directory change
eval "$(fnm env --use-on-cd --shell zsh)"
# Enable fnm completions for zsh
eval "$(fnm completions --shell zsh)"
# Optional: Auto-install Node.js version if .node-version exists but version not installed
# Uncomment the following lines to enable this feature:
# autoload -U add-zsh-hook
# _fnm_autoinstall() {
# if [[ -f .node-version || -f .nvmrc ]]; then
# local version
# if [[ -f .node-version ]]; then
# version="$(cat .node-version)"
# elif [[ -f .nvmrc ]]; then
# version="$(cat .nvmrc)"
# fi
# if ! fnm list | grep -q "$version"; then
# echo "Auto-installing Node.js $version..."
# fnm install "$version"
# fi
# fi
# }
# add-zsh-hook chpwd _fnm_autoinstall
# _fnm_autoinstall # Run on shell startup
fi
FNM_PATH="/root/.local/share/fnm"
if [ -d "$FNM_PATH" ]; then
export PATH="/root/.local/share/fnm:$PATH"
eval "`fnm env`"
fi

View File

@@ -4,14 +4,4 @@ nvm() {
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm "$@"
}
node() {
unset -f node
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
node "$@"
}
npm() {
unset -f npm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
npm "$@"
}