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 # fnm (Fast Node Manager) configuration
# https://github.com/Schniz/fnm # https://github.com/Schniz/fnm
# Check if fnm is installed FNM_PATH="/root/.local/share/fnm"
if command -v fnm &> /dev/null; then if [ -d "$FNM_PATH" ]; then
# Set fnm environment variables and enable auto-switching on directory change export PATH="/root/.local/share/fnm:$PATH"
eval "$(fnm env --use-on-cd --shell zsh)" eval "`fnm env`"
# 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 fi

View File

@@ -5,13 +5,3 @@ nvm() {
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm "$@" 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 "$@"
}