zsh:autoload: Load wrapper only if command exists
This commit is contained in:
@@ -9,8 +9,21 @@ autoload -Uz run-help run-help-git zmv
|
|||||||
|
|
||||||
# Load autoloadable functions
|
# Load autoloadable functions
|
||||||
if [[ -d "$ZDOTDIR/autoload" ]]; then
|
if [[ -d "$ZDOTDIR/autoload" ]]; then
|
||||||
# Include all subdirectories
|
# Include all wrapper scripts if their wrapped command exists
|
||||||
|
d="$ZDOTDIR/autoload/wrapper"
|
||||||
|
if [[ -d "$d" ]]; then
|
||||||
|
fpath=("$d" $fpath)
|
||||||
|
for f in "$d"/[^_.]*(.xN:t); do
|
||||||
|
(( $+commands[$f] )) || continue
|
||||||
|
autoload -Uz -- "$f"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Include all other subdirectories
|
||||||
for d in "$ZDOTDIR/autoload/"*(/N); do
|
for d in "$ZDOTDIR/autoload/"*(/N); do
|
||||||
|
# EXTENDED_GLOB is not yet set, so we have to exclude manually
|
||||||
|
[[ ${d:t} != wrapper ]] || continue
|
||||||
|
|
||||||
fpath=("$d" $fpath)
|
fpath=("$d" $fpath)
|
||||||
autoload -Uz -- "" "$d"/[^_.]*(.xN:t)
|
autoload -Uz -- "" "$d"/[^_.]*(.xN:t)
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user