From 46ddca33fb886be8c6fc2c549864bd3ced065df1 Mon Sep 17 00:00:00 2001 From: a5ob7r <12132068+a5ob7r@users.noreply.github.com> Date: Sun, 10 Apr 2022 19:40:28 +0900 Subject: [PATCH] :bug: Fix a duplicate path addition The previous path addition doesn't have a guard statement. It probably spawns value duplicated $PATH such as 'PATH=/a/path:~/.exa/bin:~/.exa/bin:~/.exa/bin' when runs nested zsh. So adds a guard statement to check whether or not the exa bin directory path exists in $PATH. $PATH is exported by default, so no need to re-export explicitly. And $path is a tied variable to $PATH, so we can think as it is exported too. --- zsh-exa.plugin.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zsh-exa.plugin.zsh b/zsh-exa.plugin.zsh index 23ed85d..bc2b802 100755 --- a/zsh-exa.plugin.zsh +++ b/zsh-exa.plugin.zsh @@ -92,8 +92,12 @@ update_zsh_exa() { } _zsh_exa_load() { - # export PATH - export PATH=${PATH}:${EXA_HOME}/bin + local -r exadir=$EXA_HOME/bin + + # Add the exa bin directory path if it doesn't exist in $PATH. + if [[ -z ${path[(r)$exadir]} ]]; then + path+=($exadir) + fi } # install exa if it isnt already installed