zshlibs/zconfig.funcs.zsh

83 lines
2.3 KiB
Bash
Raw Normal View History

2022-01-11 16:43:02 +00:00
function zconfig_checkload()
{
typeset -a -g zconfig_loaded
if [[ ! ${zconfig_loaded[(r)${1}]} ]]
then
zshlibs_log zconfig "sourcing config '$1'"
. -- $1 2>&1 >(zshlibs_log zconfig)
zconfig_loaded+=("$1")
zshlibs_log zconfig "end sourcing config '$1'"
else
zshlibs_log zconfig "config '$1' already loaded"
2022-01-11 17:12:50 +00:00
zshlibs_log zconfig "currently loaded configs: ${zconfig_loaded}"
2022-01-11 16:43:02 +00:00
fi
}
function zconfigs_load()
{
2022-01-11 17:06:09 +00:00
zshlibs_log zconfig "loading supplied config names"
2022-01-11 16:43:02 +00:00
for configfile in ${*}; do
zconfig_checkload $configfile
done
}
function zconfigs_local_load()
{
if [[ ! -a ${zconfig_local_path} ]]; then
2022-01-11 17:01:52 +00:00
zshlibs_log zconfig "local config missing, recreating from '${zconfig_shared_path}/zshconfig.example'"
2022-01-11 21:03:44 +00:00
mkdir -p -m 700 "${zconfig_local_path}"
2022-01-11 16:43:02 +00:00
cp ${zconfig_shared_path}/zshconfig.example ${zconfig_local_path}/local.config.zsh
fi
if [[ ! -d ${zconfig_local_path} ]]; then
2022-01-11 17:01:52 +00:00
zshlibs_log zconfig "local config appears to be a file, loading '${zconfig_local_path}'"
2022-01-11 16:43:02 +00:00
zconfig_checkload ${zconfig_local_path}
else
2022-01-11 17:01:52 +00:00
zshlibs_log zconfig "local config is a directory, loading '${zconfig_local_path}/*.config.zsh'"
2022-01-11 16:43:02 +00:00
zconfigs_load ${zconfig_local_path}/*.config.zsh;
fi
}
# zconfig bootup
function zconfig_boot()
{
zconfig_configure
zconfig_setup
zconfig_setup_interactive
}
function zconfig_configure()
{
typeset -a -g zconfig_loaded
typeset -a -g config_extra # user populatable config names in zshlibs location
typeset -g zconfig_shared_path="${zshlibs_install}/config"
typeset -g zconfig_local_path="${HOME}/.config/zsh"
}
function zbootstrap_noninteractive()
{
zshlibs_log zconfig "WARNING: legacy function called"
zconfig_configure
zconfig_setup
}
function zconfig_setup()
{
zshlibs_log zconfig 'load global config'
zconfig_checkload ${zconfig_shared_path}/global.config.zsh
zshlibs_log zconfig 'load local configs'
zconfigs_local_load
for zconfig in $config_extra; do
zshlibs_log zconfig 'load config extra $zconfig'
zconfig_checkload ${zconfig_shared_path}/${zconfig}.config.zsh
done
}
function zconfig_setup_interactive()
{
zshlibs_log zconfig "loading interactive config"
zconfig_checkload ${zconfig_shared_path}/global.style.zsh
zshlibs_log zconfig "done loading interactive config"
}