From 2cac94f9c3aa9797a8b86921cb01c96eee013a7f Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 12 Dec 2024 08:10:56 +0100 Subject: fix(zshrc): don't append PATH if already present --- user/zsh/.zshrc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'user/zsh') diff --git a/user/zsh/.zshrc b/user/zsh/.zshrc index 2e9d521..ba07dc2 100644 --- a/user/zsh/.zshrc +++ b/user/zsh/.zshrc @@ -55,8 +55,13 @@ export INPUTRC=$XDG_CONFIG_HOME/readline/inputrc export NPM_CONFIG_PREFIX="$HOME/.local/npm" export PYTHON_BASIC_REPL=1 # use readline (Python >=3.13 defaults to its own REPL which has no vi keybindings) -export PATH="$PATH:$HOME/.cargo/bin" -export PATH="$PATH:$NPM_CONFIG_PREFIX/bin" +# If we'd extend the PATH with PATH=$PATH:extra the PATH would become longer with each subshell. +# In ZSH PATH is tied to the $path array. We force that array to have unique values: +typeset -U path PATH +# Now we can append PATH entries with path+=... without the PATH growing in each subshell. + +path+=~/.cargo/bin +path+=($NPM_CONFIG_PREFIX/bin) ## Completion autoload -Uz compinit -- cgit v1.2.3