From 883e83f89abf5042ce98250587ccc3c6e72d365a Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Tue, 28 Dec 2021 14:15:09 +0100 Subject: [PATCH] Fix PATH environment after plugins ran This is especially important to keep the desired search order in place when other plugins appended/prepended paths. --- core/30_path/30_path.zprofile | 67 +++++++++++++++++++---------------- core/50_path/50_path.zprofile | 9 +++++ 2 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 core/50_path/50_path.zprofile diff --git a/core/30_path/30_path.zprofile b/core/30_path/30_path.zprofile index 32da563..a15e006 100644 --- a/core/30_path/30_path.zprofile +++ b/core/30_path/30_path.zprofile @@ -10,38 +10,43 @@ fi typeset -Ux PATH typeset -U path -# Prepend additional search paths -for d ( - /Developer/usr/bin - /usr/ucb - /usr/pkg/bin - /usr/local/bin - /usr/local/sbin - /opt/*/bin(NOn) - /opt/*/sbin(NOn) - /home/linuxbrew/.linuxbrew/bin - /home/linuxbrew/.linuxbrew/sbin - ~/.linuxbrew/bin - ~/.linuxbrew/sbin - ~/.gem/ruby/*/bin(NOn) - ~/.go/bin - ~/.cargo/bin - ~/.local/bin - ~/bin - ~/sbin - ~/Applications -); do - [[ -d "$d" ]] && path=("$d" $path) -done +_axzsh_setup_path() { + # Prepend additional search paths + for d ( + /Developer/usr/bin + /usr/ucb + /usr/pkg/bin + /usr/local/bin + /usr/local/sbin + /opt/*/bin(NOn) + /opt/*/sbin(NOn) + /home/linuxbrew/.linuxbrew/bin + /home/linuxbrew/.linuxbrew/sbin + ~/.linuxbrew/bin + ~/.linuxbrew/sbin + ~/.gem/ruby/*/bin(NOn) + ~/.go/bin + ~/.cargo/bin + ~/.local/bin + ~/bin + ~/sbin + ~/Applications + ); do + [[ -d "$d" ]] && path=("$d" $path) + done + + # Append additional search paths + for d ( + /usr/X11/bin + /usr/local/games + /usr/games + ); do + [[ -d "$d" ]] && path=($path "$d") + done +} -# Append additional search paths -for d ( - /usr/X11/bin - /usr/local/games - /usr/games -); do - [[ -d "$d" ]] && path=($path "$d") -done +# Prepend and append search paths (in a special order!) +_axzsh_setup_path # Set default MANPATH MANPATH="$(manpath -q)" 2>/dev/null diff --git a/core/50_path/50_path.zprofile b/core/50_path/50_path.zprofile new file mode 100644 index 0000000..eaab8fd --- /dev/null +++ b/core/50_path/50_path.zprofile @@ -0,0 +1,9 @@ +# # AX-ZSH: Alex' Modular ZSH Configuration +# 50_path.zprofile: Fix PATH environment after plugins ran + +# Prepend and append search paths (in a special order!) +_axzsh_setup_path +unfunction _axzsh_setup_path + +typeset -Ux PATH MANPATH +typeset -U path manpath -- 2.39.2