Compare commits

...

2 Commits

Author SHA1 Message Date
31f67370ed
split global 2024-01-18 19:32:40 +04:00
c72676ccac
split zconfig, adjust zssh 2024-01-18 19:29:40 +04:00
21 changed files with 131 additions and 155 deletions

View File

@ -1,63 +0,0 @@
typeset -g globaldots_path="${HOME}/.global"
if [[ -a $(realpath -m $(dirname $0)/../../.globaldir ) ]]
then
typeset -g globaldots_path=$(realpath -m $(dirname $0)/../../)
fi
if [[ -n ${GLOBALDOTS_PATH} ]]
then
typeset -g globaldots_path=${GLOBALDOTS_PATH}
fi
if [[ -z $globaldots_path ]]; then
echo 'functions require $globaldots_path to be set!'
fi
# ZCONFIG
## stuff for global dotfiles
function global_path_expand()
{
local bin_base=${globaldots_path}/bin
for pathnew in ${*}; do
zshlibs_path_add "${bin_base}/${pathnew}"
done;
}
function global_fpath_expand()
{
local bin_base=${globaldots_path}/bin
for pathnew in ${*}; do
zshlibs_fpath_add "${bin_base}/${pathnew}"
done;
}
function global_set_useropts()
{
typeset -a -g path_extra
}
function global_configure()
{
typeset -a -g path_extra
}
function global_config_setup()
{
zshlibs_log global "expanding path with '$path_extra'"
global_path_expand $path_extra
zshlibs_log global "expanding fpath with '$fpath_extra'"
global_fpath_expand vanilla
zshlibs_log global "done loading noninteractive config"
}
function global_boot()
{
global_configure
global_config_setup
}
## normal functions

18
global.zsh Normal file
View File

@ -0,0 +1,18 @@
typeset -g globaldots_path="${HOME}/.global"
if [[ -a $(realpath -m $(dirname $0)/../../.globaldir ) ]]
then
typeset -g globaldots_path=$(realpath -m $(dirname $0)/../../)
fi
if [[ -n ${GLOBALDOTS_PATH} ]]
then
typeset -g globaldots_path=${GLOBALDOTS_PATH}
fi
if [[ -z $globaldots_path ]]; then
echo 'functions require $globaldots_path to be set!'
fi
autoload global_path_expand global_fpath_expand global_set_useropts \
global_configure global_config_setup global_boot
fpath+=(${zshlibs_install}/global)

5
global/global_boot Normal file
View File

@ -0,0 +1,5 @@
function global_boot()
{
global_configure
global_config_setup
}

View File

@ -0,0 +1,8 @@
function global_config_setup()
{
zshlibs_log global "expanding path with '$path_extra'"
global_path_expand $path_extra
zshlibs_log global "expanding fpath with '$fpath_extra'"
global_fpath_expand vanilla
zshlibs_log global "done loading noninteractive config"
}

4
global/global_configure Normal file
View File

@ -0,0 +1,4 @@
function global_configure()
{
typeset -a -g path_extra
}

View File

@ -0,0 +1,7 @@
function global_fpath_expand()
{
local bin_base=${globaldots_path}/bin
for pathnew in ${*}; do
zshlibs_fpath_add "${bin_base}/${pathnew}"
done;
}

View File

@ -0,0 +1,7 @@
function global_path_expand()
{
local bin_base=${globaldots_path}/bin
for pathnew in ${*}; do
zshlibs_path_add "${bin_base}/${pathnew}"
done;
}

View File

@ -0,0 +1,4 @@
function global_set_useropts()
{
typeset -a -g path_extra
}

View File

@ -1,6 +1,6 @@
autoload zshlibs_boot zshlibs_log zshlibs_ensure zshlibs_fpath_add \
zshlibs_path_add zshlibs_start zshlibs_update
function zbootstrap()
{
autoload zshlibs_boot zshlibs_log zshlibs_ensure zshlibs_fpath_add \
zshlibs_path_add zshlibs_start zshlibs_update
zshlibs_start
}

View File

@ -15,8 +15,7 @@ else
zshlibs_update
fi
source ${zshlibs_install}/tools.zsh
source ${zshlibs_install}/zconfig.funcs.zsh
source ${zshlibs_install}/global.funcs.zsh
source ${zshlibs_install}/zconfig.zsh
source ${zshlibs_install}/global.zsh
source ${zshlibs_install}/zssh.zsh

View File

@ -1,82 +0,0 @@
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"
zshlibs_log zconfig "currently loaded configs: ${zconfig_loaded}"
fi
}
function zconfigs_load()
{
zshlibs_log zconfig "loading supplied config names"
for configfile in ${*}; do
zconfig_checkload $configfile
done
}
function zconfigs_local_load()
{
if [[ ! -a ${zconfig_local_path} ]]; then
zshlibs_log zconfig "local config missing, recreating from '${zconfig_shared_path}/zshconfig.example'"
mkdir -p -m 700 "${zconfig_local_path}"
cp ${zconfig_shared_path}/zshconfig.example ${zconfig_local_path}/local.config.zsh
fi
if [[ ! -d ${zconfig_local_path} ]]; then
zshlibs_log zconfig "local config appears to be a file, loading '${zconfig_local_path}'"
zconfig_checkload ${zconfig_local_path}
else
zshlibs_log zconfig "local config is a directory, loading '${zconfig_local_path}/*.config.zsh'"
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"
}

4
zconfig.zsh Normal file
View File

@ -0,0 +1,4 @@
fpath+=(${zshlibs_install}/zconfig)
autoload zconfig_boot zconfig_checkload zconfig_configure \
zconfig_setup zconfig_setup_interactive zconfigs_load \
zconfigs_local_load

6
zconfig/zconfig_boot Normal file
View File

@ -0,0 +1,6 @@
function zconfig_boot()
{
zconfig_configure
zconfig_setup
zconfig_setup_interactive
}

14
zconfig/zconfig_checkload Normal file
View File

@ -0,0 +1,14 @@
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"
zshlibs_log zconfig "currently loaded configs: ${zconfig_loaded}"
fi
}

View File

@ -0,0 +1,7 @@
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"
}

11
zconfig/zconfig_setup Normal file
View File

@ -0,0 +1,11 @@
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
}

View File

@ -0,0 +1,6 @@
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"
}

7
zconfig/zconfigs_load Normal file
View File

@ -0,0 +1,7 @@
function zconfigs_load()
{
zshlibs_log zconfig "loading supplied config names"
for configfile in ${*}; do
zconfig_checkload $configfile
done
}

View File

@ -0,0 +1,15 @@
function zconfigs_local_load()
{
if [[ ! -a ${zconfig_local_path} ]]; then
zshlibs_log zconfig "local config missing, recreating from '${zconfig_shared_path}/zshconfig.example'"
mkdir -p -m 700 "${zconfig_local_path}"
cp ${zconfig_shared_path}/zshconfig.example ${zconfig_local_path}/local.config.zsh
fi
if [[ ! -d ${zconfig_local_path} ]]; then
zshlibs_log zconfig "local config appears to be a file, loading '${zconfig_local_path}'"
zconfig_checkload ${zconfig_local_path}
else
zshlibs_log zconfig "local config is a directory, loading '${zconfig_local_path}/*.config.zsh'"
zconfigs_load ${zconfig_local_path}/*.config.zsh;
fi
}

View File

@ -1,3 +1,6 @@
fpath+=(${zshlibs_install}/zssh/)
autoload zssh_boot
autoload zssh_configure zssh_process zssh_check_pubkeys zssh_enumeratenodes \
zssh_generate_config4 zssh_generate_hostaccessconfig zssh_generate_privkey4 \
zssh_host_info zssh_install_peers zssh_mail_pubkey2 zssh_node_info \
zssh_publish_configs zssh_publish_pubkeys zssh_boot

View File

@ -7,10 +7,6 @@ function zssh_boot()
typeset -g zssh_private_configs="${zssh_ssh_dotdir}/config.d"
typeset -g zssh_global_configs=${globaldots_path}/config/ssh
typeset -g zssh_global_pubkeys=${globaldots_path}/keys/ssh
autoload zssh_configure zssh_process zssh_check_pubkeys zssh_enumeratenodes \
zssh_generate_config4 zssh_generate_hostaccessconfig zssh_generate_privkey4 \
zssh_host_info zssh_install_peers zssh_mail_pubkey2 zssh_node_info \
zssh_publish_configs zssh_publish_pubkeys
zssh_configure
zssh_process
}