Skip to content

Commit dc0e6e8

Browse files
committed
fix: running nvm stuff in a non-interactive subshell
1 parent b8abf18 commit dc0e6e8

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

zsh/nvm.zsh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22
export NVM_DIR="$HOME/.config/nvm"
33
if [ -s "$NVM_DIR/nvm.sh" ]; then
44
# Define commands that should trigger nvm initialization
5-
local nvm_commands=(nvm node npm npx yarn claude-code-acp)
5+
_nvm_commands=(nvm node npm npx yarn claude-code-acp clasp)
66

77
# Initialize nvm once when any node-related command is first used
88
_load_nvm() {
9-
# Unset all wrapper functions
10-
unset -f "${nvm_commands[@]}"
9+
# Hardcoded list (not the array) so this works even when _nvm_commands is
10+
# unavailable in the calling context (e.g. non-interactive subshells)
11+
unset -f nvm node npm npx yarn clasp claude-code-acp clasp _load_nvm 2>/dev/null
12+
# Stub compdef to silence "invalid subscript range" errors when nvm.sh is
13+
# sourced after prezto has already run compinit. Unsetting restores the real
14+
# autoloaded compdef for subsequent calls.
15+
compdef() {; }
1116
source "$NVM_DIR/nvm.sh"
1217
[ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion"
18+
unset -f compdef
1319
}
1420

1521
# Create wrapper functions that trigger nvm initialization
16-
for cmd in "${nvm_commands[@]}"; do
22+
for cmd in "${_nvm_commands[@]}"; do
1723
eval "${cmd}() { _load_nvm && ${cmd} \"\$@\"; }"
1824
done
19-
fi
25+
fi

zsh/zshrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
source $HOME/.zprezto/runcoms/zshrc
22

33
for config_file ($HOME/.yadr/zsh/*.zsh) source $config_file
4+
5+
# Added by LM Studio CLI (lms)
6+
export PATH="$PATH:/Users/lgonzaga/.lmstudio/bin"
7+
# End of LM Studio CLI section
8+

0 commit comments

Comments
 (0)