zsh/modules/autoloader/init

45 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/zsh
#################################################################################
# ZSH zle widget and custom function autloader
#################################################################################
#
# Lets you load custom functions and zle widgets split into single files.
#
# zle widgets are stored in the "widgets" folder in your configuration directory
2016-07-25 11:48:52 +00:00
# (set with $ZDOTDIR, see manpage). The widgets in /etc/zsh/widgets are also
# considered.
#
# functions are stored in the "functions" folder analogous.
#
2016-07-25 11:48:52 +00:00
if [[ -z $ZWIDGETPATH ]]; then
ZWIDGETPATH=( ${ZDOTDIR:+$ZDOTDIR/widgets} )
[[ -d /etc/zsh/widgets ]] && ZWIDGETPATH+=/etc/zsh/widgets
fi
2016-07-25 11:48:52 +00:00
if [[ -z $ZFUNCTIONPATH ]]; then
ZFUNCTIONPATH=( ${ZDOTDIR:+$ZDOTDIR/functions} )
[[ -d /etc/zsh/functions ]] && ZFUNCTIONPATH+=/etc/zsh/functions
fi
2016-07-25 11:48:52 +00:00
fpath+=(${ZWIDGETPATH})
fpath+=(${ZFUNCTIONPATH})
for dir in $ZWIDGETPATH; do
if [ -d $dir ]; then
for i in $dir/*~*.zwc(N:t); do
autoload -Uz $i
zle -N $i
done
fi
done
for dir in $ZFUNCTIONPATH; do
if [ -d $dir ]; then
for i in $dir/*~*.zwc(N:t); do
2019-02-11 14:36:37 +00:00
autoload -Uz $i
2016-07-25 11:48:52 +00:00
done
fi
done