zsh: move/hide initialization
this also improves .zsh bytecode compilation
This commit is contained in:
parent
d2061dda65
commit
086279d721
59
.config/zsh/_.zsh
Normal file
59
.config/zsh/_.zsh
Normal file
@ -0,0 +1,59 @@
|
||||
#!/bin/zsh
|
||||
|
||||
: "${ZDOTDIR:=${HOME}}"
|
||||
|
||||
typeset -gA ZSHU
|
||||
|
||||
ZSHU[t_begin]=${(%):-%D{%s.%6.}}
|
||||
|
||||
ZSHU[d_zdot]="${ZDOTDIR}"
|
||||
ZSHU[d_cache]="${ZDOTDIR}/.cache/zsh"
|
||||
ZSHU[d_conf]="${ZDOTDIR}/.config/zsh"
|
||||
|
||||
ZSHU[d_var]="${ZSHU[d_conf]}/var"
|
||||
|
||||
ZSHU[d_bin]="${ZDOTDIR}/.config/dotfiles/bin/"
|
||||
|
||||
for i ( d_zdot d_cache d_conf d_bin d_var ) ; do
|
||||
d=${ZSHU[$i]}
|
||||
[ -d "$d" ] || mkdir -p "$d"
|
||||
done ; unset i d
|
||||
|
||||
## early escape
|
||||
unsetopt GLOBAL_RCS
|
||||
|
||||
## safety measure:
|
||||
## redirect all following activity within ZDOTDIR to cache
|
||||
## (probably) these files are safe to remove
|
||||
ZDOTDIR="${ZSHU[d_cache]}"
|
||||
rm -f "${ZDOTDIR}/.zshrc" "${ZDOTDIR}/.zlogin"
|
||||
|
||||
## cleanup: start from scratch
|
||||
for i ( a s f d ) ; do unhash -$i -m '*' ; done ; unset i
|
||||
|
||||
## set default umask
|
||||
umask 0022
|
||||
|
||||
zshu_parts=( env opt lib rc alias local )
|
||||
|
||||
for n ( $zshu_parts ) ; do
|
||||
f="${ZSHU[d_conf]}/$n.zsh"
|
||||
[ -s "$f" ] && source "$f"
|
||||
done ; unset n f
|
||||
|
||||
for n ( $zshu_parts ) ; do
|
||||
d="${ZSHU[d_conf]}/$n"
|
||||
[ -d "$d" ] || continue
|
||||
for i ( $d/*.zsh(N.r) ) ; do
|
||||
source "$i"
|
||||
done ; unset i
|
||||
done ; unset n d
|
||||
|
||||
unset zshu_parts
|
||||
|
||||
ZSHU[t_end]=${(%):-%D{%s.%6.}}
|
||||
|
||||
ZSHU[t_load]=$(( ZSHU[t_end] - ZSHU[t_begin] ))
|
||||
ZSHU[t_load]=${ZSHU[t_load]:0:6}
|
||||
|
||||
unset "ZSHU[t_begin]" "ZSHU[t_end]"
|
60
.zshenv
60
.zshenv
@ -1,62 +1,6 @@
|
||||
#!/bin/zsh
|
||||
|
||||
if [[ -o interactive ]] ; then
|
||||
|
||||
## early redirect
|
||||
: "${ZDOTDIR:=${HOME}}"
|
||||
|
||||
typeset -gA ZSHU
|
||||
|
||||
ZSHU[t_begin]=${(%):-%D{%s.%6.}}
|
||||
|
||||
ZSHU[d_zdot]="${ZDOTDIR}"
|
||||
ZSHU[d_cache]="${ZDOTDIR}/.cache/zsh"
|
||||
ZSHU[d_conf]="${ZDOTDIR}/.config/zsh"
|
||||
|
||||
ZSHU[d_var]="${ZSHU[d_conf]}/var"
|
||||
|
||||
ZSHU[d_bin]="${ZDOTDIR}/.config/dotfiles/bin/"
|
||||
|
||||
for i ( d_zdot d_cache d_conf d_bin d_var ) ; do
|
||||
d=${ZSHU[$i]}
|
||||
[ -d "$d" ] || mkdir -p "$d"
|
||||
done ; unset i d
|
||||
|
||||
## early escape
|
||||
unsetopt GLOBAL_RCS
|
||||
|
||||
## safety measure:
|
||||
## redirect all following activity within ZDOTDIR to cache
|
||||
## (probably) these files are safe to remove
|
||||
ZDOTDIR="${ZSHU[d_cache]}"
|
||||
rm -f "${ZDOTDIR}/.zshrc" "${ZDOTDIR}/.zlogin"
|
||||
|
||||
## cleanup: start from scratch
|
||||
for i ( a s f d ) ; do unhash -$i -m '*' ; done ; unset i
|
||||
|
||||
## set default umask
|
||||
umask 0022
|
||||
|
||||
zshu_parts=( env opt lib rc alias local )
|
||||
|
||||
for n ( $zshu_parts ) ; do
|
||||
f="${ZSHU[d_conf]}/$n.zsh"
|
||||
[ -s "$f" ] && source "$f"
|
||||
done ; unset n f
|
||||
|
||||
for n ( $zshu_parts ) ; do
|
||||
d="${ZSHU[d_conf]}/$n"
|
||||
[ -d "$d" ] || continue
|
||||
for i ( $d/*.zsh(N.r) ) ; do
|
||||
source "$i"
|
||||
done ; unset i
|
||||
done ; unset n d
|
||||
|
||||
unset zshu_parts
|
||||
|
||||
ZSHU[t_end]=${(%):-%D{%s.%6.}}
|
||||
|
||||
ZSHU[t_load]=$(( ZSHU[t_end] - ZSHU[t_begin] ))
|
||||
ZSHU[t_load]=${ZSHU[t_load]:0:6}
|
||||
|
||||
unset "ZSHU[t_begin]" "ZSHU[t_end]"
|
||||
source "${ZDOTDIR}/.config/zsh/_.zsh"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user