zshenv (1515B)
1 () { 2 # If $ZDOTDIR is not set and none of .zshenv, .zprofile, .zshrc, .zlogin exist 3 # in $HOME, read ZSH startup files from $XDG_CONFIG_HOME/zsh/ instead of $HOME. 4 # The point is to promote XDG-based location, but don't break existing setups. 5 [[ -n "${ZDOTDIR-}" ]] && return 6 setopt localoptions extendedglob nullglob 7 local -a _xdgrcs _homercs 8 _homercs=( "$HOME"/.z(shenv|profile|shrc|login) ) 9 if (( $#_homercs )); then 10 [[ -o interactive ]] || return 11 _xdgrcs=( ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.z(shenv|profile|shrc|login) ) 12 if (( $#_xdgrcs )); then 13 local _c=${XDG_CONFIG_HOME:-$HOME/.config}/zsh 14 printf '%s\n' >&2 \ 15 "Warning: Found Zsh startup files both in ~/ and $_c" \ 16 " the latter will be ignored (tip: move $_homercs to $_c/)." 17 fi 18 else 19 ZDOTDIR=${XDG_CONFIG_HOME:-$HOME/.config}/zsh 20 fpath=( $ZDOTDIR/functions $fpath ) 21 fi 22 } 23 24 () { 25 [[ -o rcs ]] || return 26 27 (($+site_rc_blacklist)) || typeset -ga site_rc_blacklist 28 29 if ! (($+site_rcs_enable)); then 30 if ! [[ -o GLOBAL_RCS ]]; then 31 site_rcs_enable=0 32 elif [[ -f ${ZDOTDIR:-$HOME}/.zsh_site_rcs ]]; then 33 site_rcs_enable=1 34 autoload -Uz site_rc 35 source ${ZDOTDIR:-$HOME}/.zsh_site_rcs 36 else 37 local -a site_rcs_dotfiles 38 site_rcs_dotfiles=( ${ZDOTDIR:-$HOME}/.z(profile|login|sh(rc|env))(N) ) 39 if (($#site_rcs_dotfiles)); then 40 site_rcs_enable=0 41 else 42 site_rcs_enable=1 43 autoload -Uz site_rc 44 fi 45 fi 46 fi 47 48 (($site_rcs_enable)) && site_rc zshenv 49 } 50 # vim: ft=zsh noet ts=4 sts=4 sw=4