summaryrefslogtreecommitdiff
path: root/user/zsh/.zshrc
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2024-12-12 08:10:56 +0100
committerMartin Fischer <martin@push-f.com>2024-12-12 08:10:56 +0100
commit2cac94f9c3aa9797a8b86921cb01c96eee013a7f (patch)
tree3e721984b76b39a6dd340c73df773330478a808d /user/zsh/.zshrc
parentb1d0bb8674083dac66433c291e0fb24d815252f3 (diff)
fix(zshrc): don't append PATH if already present
Diffstat (limited to 'user/zsh/.zshrc')
-rw-r--r--user/zsh/.zshrc9
1 files changed, 7 insertions, 2 deletions
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