[zsh] Process fpath candidate paths in a loop in init-env-fpath
This commit is contained in:
parent
80e2915b89
commit
a026b9c8a9
1 changed files with 13 additions and 8 deletions
19
zshenv
19
zshenv
|
@ -7,15 +7,20 @@ export SYS=`uname -s | tr A-Z a-z`
|
||||||
|
|
||||||
function init-env-fpath
|
function init-env-fpath
|
||||||
{
|
{
|
||||||
local user_fpath=("$HOME/.zsh/func")
|
local -r fpath_candidates=( \
|
||||||
|
"$HOME/.zsh/${SYS}-functions" \
|
||||||
|
"$HOME/.zsh/func" \
|
||||||
|
)
|
||||||
|
|
||||||
local sys_fpath="$HOME/.zsh/func/$SYS"
|
# Process the array in reverse order (`Oa` means "descending index order",
|
||||||
if [[ -d "$sys_fpath" ]]; then
|
# in other worse "reverse order"; see PARAMETER EXPANSION section of the man
|
||||||
user_fpath+=($sys_fpath)
|
# pages) so the paths are prepended in the correct order.
|
||||||
|
for candidate in ${(Oa)fpath_candidates}; do
|
||||||
|
if [[ ! -d "$candidate" ]]; then
|
||||||
|
continue
|
||||||
fi
|
fi
|
||||||
|
fpath=($candidate $fpath)
|
||||||
fpath=($user_fpath $fpath)
|
done
|
||||||
export FPATH
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init-env-fpath
|
init-env-fpath
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue