diff --git a/tools.funcs.zsh b/tools.funcs.zsh deleted file mode 100644 index a0999e9..0000000 --- a/tools.funcs.zsh +++ /dev/null @@ -1,90 +0,0 @@ - -function zshlibs_boot() -{ - typeset -g zshlibs_bootlevel - if [[ $zshlibs_bootlevel -gt 1 ]] - then - echo "You are likely doing double bootstrap" - fi - zshlibs_bootlevel=0 - zshlibs_log zbootstrap "ensure directory '${HOME}/.log/'" - zshlibs_ensure -d "${HOME}/.log/" - zshlibs_bootlevel=2 -} - -function zshlibs_ensure() -{ - target="${2}" - typ="${1}" - if ! test -e "${target}" - then - zshlibs_log zshlibs_ensure "creating '${target}' ($typ) …" - case $typ in - -d) - mkdir -p "${target}" \ - || zshlibs_log $0 "unable to create directory '${target}'" \ - && return 2 - ;; - -f) - touch "${target}" \ - || zshlibs_log $0 "unable to create file '${target}'" \ - && return 2 - esac - zshlibs_log zshlibs_ensure "target '${target}' created" - elif test "${typ}" "${target}" - then - zshlibs_log zshlibs_ensure "target '${target}' ($typ) present" - return 0 - else - zshlibs_log zshlibs_ensure "target '${target}' already exists and it is not a directory" - return 1 - fi -} - -function zshlibs_log() -{ - local facility=$1 - shift - if [[ -n "${@}" ]] - then - echo "$(date -Ins) ${@}" >> "${HOME}/.log/z_$facility.log" - else - echo "$(date -Ins) $(cat)" >> "${HOME}/.log/z_$facility.log" - fi -} - -function zshlibs_path_add() -{ - local pathtoadd="${1}" - zshlibs_log $0 "adding path '$pathtoadd' to \$PATH" - if [[ ! ${path[(r)${pathtoadd}]} ]] - then - path+=(${pathtoadd}) - fi -} - -function zshlibs_fpath_add() -{ - local fpathtoadd="${1}" - zshlibs_log $0 "adding fpath '$fpathtoadd' to \$fpath" - if [[ ! ${fpath[(r)${fpathtoadd}]} ]] - then - path+=(${fpathtoadd}) - fi -} - -function zshlibs_start() -{ - zshlibs_boot - zshlibs_update - zconfig_boot - global_boot - zssh_boot - zshlibs_log zbootstrap "zshlibs booted up -===========================================" -} - -function zbootstrap() -{ - zshlibs_start -} diff --git a/tools.zsh b/tools.zsh new file mode 100644 index 0000000..d7bb68c --- /dev/null +++ b/tools.zsh @@ -0,0 +1,6 @@ +function zbootstrap() +{ + autoload zshlibs_boot zshlibs_log zshlibs_ensure zshlibs_fpath_add \ + zshlibs_path_add zshlibs_start zshlibs_update + zshlibs_start +} diff --git a/tools/zshlibs_boot b/tools/zshlibs_boot new file mode 100644 index 0000000..3a10cd7 --- /dev/null +++ b/tools/zshlibs_boot @@ -0,0 +1,12 @@ +function zshlibs_boot() +{ + typeset -g zshlibs_bootlevel + if [[ $zshlibs_bootlevel -gt 1 ]] + then + echo "You are likely doing double bootstrap" + fi + zshlibs_bootlevel=0 + zshlibs_log zbootstrap "ensure directory '${HOME}/.log/'" + zshlibs_ensure -d "${HOME}/.log/" + zshlibs_bootlevel=2 +} diff --git a/tools/zshlibs_ensure b/tools/zshlibs_ensure new file mode 100644 index 0000000..8e4e743 --- /dev/null +++ b/tools/zshlibs_ensure @@ -0,0 +1,28 @@ +function zshlibs_ensure() +{ + target="${2}" + typ="${1}" + if ! test -e "${target}" + then + zshlibs_log zshlibs_ensure "creating '${target}' ($typ) …" + case $typ in + -d) + mkdir -p "${target}" \ + || zshlibs_log $0 "unable to create directory '${target}'" \ + && return 2 + ;; + -f) + touch "${target}" \ + || zshlibs_log $0 "unable to create file '${target}'" \ + && return 2 + esac + zshlibs_log zshlibs_ensure "target '${target}' created" + elif test "${typ}" "${target}" + then + zshlibs_log zshlibs_ensure "target '${target}' ($typ) present" + return 0 + else + zshlibs_log zshlibs_ensure "target '${target}' already exists and it is not a directory" + return 1 + fi +} diff --git a/tools/zshlibs_fpath_add b/tools/zshlibs_fpath_add new file mode 100644 index 0000000..f79cb5d --- /dev/null +++ b/tools/zshlibs_fpath_add @@ -0,0 +1,9 @@ +function zshlibs_fpath_add() +{ + local fpathtoadd="${1}" + zshlibs_log $0 "adding fpath '$fpathtoadd' to \$fpath" + if [[ ! ${fpath[(r)${fpathtoadd}]} ]] + then + path+=(${fpathtoadd}) + fi +} diff --git a/tools/zshlibs_log b/tools/zshlibs_log new file mode 100644 index 0000000..fefd790 --- /dev/null +++ b/tools/zshlibs_log @@ -0,0 +1,11 @@ +function zshlibs_log() +{ + local facility=$1 + shift + if [[ -n "${@}" ]] + then + echo "$(date -Ins) ${@}" >> "${HOME}/.log/z_$facility.log" + else + echo "$(date -Ins) $(cat)" >> "${HOME}/.log/z_$facility.log" + fi +} diff --git a/tools/zshlibs_path_add b/tools/zshlibs_path_add new file mode 100644 index 0000000..a310628 --- /dev/null +++ b/tools/zshlibs_path_add @@ -0,0 +1,10 @@ +function zshlibs_path_add() +{ + local pathtoadd="${1}" + zshlibs_log $0 "adding path '$pathtoadd' to \$PATH" + if [[ ! ${path[(r)${pathtoadd}]} ]] + then + path+=(${pathtoadd}) + fi +} + diff --git a/tools/zshlibs_start b/tools/zshlibs_start new file mode 100644 index 0000000..0d89cc7 --- /dev/null +++ b/tools/zshlibs_start @@ -0,0 +1,10 @@ +function zshlibs_start() +{ + zshlibs_boot + zshlibs_update + zconfig_boot + global_boot + zssh_boot + zshlibs_log zbootstrap "zshlibs booted up +===========================================" +} diff --git a/tools/zshlibs_update b/tools/zshlibs_update index a66c3aa..d486790 100644 --- a/tools/zshlibs_update +++ b/tools/zshlibs_update @@ -1,5 +1,6 @@ function zshlibs_update() { + autoload zshlibs_log zshlibs_log zlibs_update "preparing self update …" if [[ -n "$zshlibs_install" ]] then diff --git a/zbootstrap.zsh b/zbootstrap.zsh index fa4253d..e04e387 100644 --- a/zbootstrap.zsh +++ b/zbootstrap.zsh @@ -16,7 +16,7 @@ else fi -source ${zshlibs_install}/tools.funcs.zsh +source ${zshlibs_install}/tools.zsh source ${zshlibs_install}/zconfig.funcs.zsh source ${zshlibs_install}/global.funcs.zsh source ${zshlibs_install}/zssh.zsh