From c72676ccacefb2e4d2445cc1b67479c48f01fb7e Mon Sep 17 00:00:00 2001 From: Aleksey Date: Thu, 18 Jan 2024 19:29:40 +0400 Subject: [PATCH] split zconfig, adjust zssh --- global.funcs.zsh => global.zsh | 0 tools.zsh | 4 +- zbootstrap.zsh | 5 +- zconfig.funcs.zsh | 82 ------------------------------- zconfig.zsh | 4 ++ zconfig/zconfig_boot | 6 +++ zconfig/zconfig_checkload | 14 ++++++ zconfig/zconfig_configure | 7 +++ zconfig/zconfig_setup | 11 +++++ zconfig/zconfig_setup_interactive | 6 +++ zconfig/zconfigs_load | 7 +++ zconfig/zconfigs_local_load | 15 ++++++ zssh.zsh | 5 +- zssh/zssh_boot | 4 -- 14 files changed, 78 insertions(+), 92 deletions(-) rename global.funcs.zsh => global.zsh (100%) delete mode 100644 zconfig.funcs.zsh create mode 100644 zconfig.zsh create mode 100644 zconfig/zconfig_boot create mode 100644 zconfig/zconfig_checkload create mode 100644 zconfig/zconfig_configure create mode 100644 zconfig/zconfig_setup create mode 100644 zconfig/zconfig_setup_interactive create mode 100644 zconfig/zconfigs_load create mode 100644 zconfig/zconfigs_local_load diff --git a/global.funcs.zsh b/global.zsh similarity index 100% rename from global.funcs.zsh rename to global.zsh diff --git a/tools.zsh b/tools.zsh index d7bb68c..aefa2c8 100644 --- a/tools.zsh +++ b/tools.zsh @@ -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 } diff --git a/zbootstrap.zsh b/zbootstrap.zsh index e04e387..af91820 100644 --- a/zbootstrap.zsh +++ b/zbootstrap.zsh @@ -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 diff --git a/zconfig.funcs.zsh b/zconfig.funcs.zsh deleted file mode 100644 index 2b8260c..0000000 --- a/zconfig.funcs.zsh +++ /dev/null @@ -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" -} diff --git a/zconfig.zsh b/zconfig.zsh new file mode 100644 index 0000000..b11bd94 --- /dev/null +++ b/zconfig.zsh @@ -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 diff --git a/zconfig/zconfig_boot b/zconfig/zconfig_boot new file mode 100644 index 0000000..b6cc726 --- /dev/null +++ b/zconfig/zconfig_boot @@ -0,0 +1,6 @@ +function zconfig_boot() +{ + zconfig_configure + zconfig_setup + zconfig_setup_interactive +} diff --git a/zconfig/zconfig_checkload b/zconfig/zconfig_checkload new file mode 100644 index 0000000..3c7954f --- /dev/null +++ b/zconfig/zconfig_checkload @@ -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 +} diff --git a/zconfig/zconfig_configure b/zconfig/zconfig_configure new file mode 100644 index 0000000..4b27dc8 --- /dev/null +++ b/zconfig/zconfig_configure @@ -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" +} diff --git a/zconfig/zconfig_setup b/zconfig/zconfig_setup new file mode 100644 index 0000000..c7d5736 --- /dev/null +++ b/zconfig/zconfig_setup @@ -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 +} diff --git a/zconfig/zconfig_setup_interactive b/zconfig/zconfig_setup_interactive new file mode 100644 index 0000000..2ceeb04 --- /dev/null +++ b/zconfig/zconfig_setup_interactive @@ -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" +} diff --git a/zconfig/zconfigs_load b/zconfig/zconfigs_load new file mode 100644 index 0000000..1aeaa02 --- /dev/null +++ b/zconfig/zconfigs_load @@ -0,0 +1,7 @@ +function zconfigs_load() +{ + zshlibs_log zconfig "loading supplied config names" + for configfile in ${*}; do + zconfig_checkload $configfile + done +} diff --git a/zconfig/zconfigs_local_load b/zconfig/zconfigs_local_load new file mode 100644 index 0000000..331ed3c --- /dev/null +++ b/zconfig/zconfigs_local_load @@ -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 +} diff --git a/zssh.zsh b/zssh.zsh index d61a9fb..c7250c2 100644 --- a/zssh.zsh +++ b/zssh.zsh @@ -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 diff --git a/zssh/zssh_boot b/zssh/zssh_boot index 7917122..e6ac75f 100644 --- a/zssh/zssh_boot +++ b/zssh/zssh_boot @@ -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 }