kakrc: Simplify and optimize the autoload function

This commit is contained in:
Frank LENORMAND 2017-05-15 22:27:22 +03:00
parent 3a0d9481ac
commit d5726c0cfd

View File

@ -24,17 +24,8 @@ def -params 1 -docstring "colorscheme <name>: enable named colorscheme" \
%sh{
autoload_directory() {
dir=$1
for rcfile in ${dir}/*.kak; do
if [ -f "$rcfile" ]; then
echo "try %{ source '${rcfile}' } catch %{ echo -debug Autoload: could not load '${rcfile}' }";
fi
done
for subdir in ${dir}/*; do
if [ -d "$subdir" ]; then
autoload_directory $subdir
fi
done
find -L "$1" -type f -name '*\.kak' \
-exec printf 'try %%{ source "%s" } catch %%{ echo -debug Autoload: could not load "%s" }\n' '{}' '{}' \;
}
localconfdir=${XDG_CONFIG_HOME:-${HOME}/.config}/kak