+[[ -v _sev_home ]] || export _sev_home=$HOME
+
+export ZDOTDIR=${XDG_CONFIG_HOME:-~/.config}/zsh
+
### load site-specific
-if [[ -f ~/.zshenv.local ]] { source ~/.zshenv.local }
+[[ -f ${ZDOTDIR:-~}/.zshenv.local ]] && source ${ZDOTDIR:-~}/.zshenv.local
+
+### fix broken term
+if [[ ! -v TERM ]] {
+ TERM=xterm-256color >/dev/null 2>&1
+}
+if [[ -o interactive && $#terminfo -eq 0 ]] {
+ _oldterm=$TERM
+ export TERM=xterm >/dev/null 2>&1
+ print -P "%F{red}!!! Can't find terminfo for $_oldterm, using $TERM%f"
+ unset _oldterm
+}
-# vim: set et sts=4 sw=4 ts=8 tw=79 :
+# NOTE: see .zprofile comment for rationale on sourcing
+if [[ ! -v _sev_first_display && ( -v DISPLAY || -v WAYLAND_DISPLAY ) ]] {
+ ### update gpgagent to use graphical pinentry
+ # XXX: will be sourced by every new child shell if zsh is not used to
+ # start the graphical session and the _sev_first_display var isn't
+ # exported; for example, this previously happened with sway without a
+ # display manager or launcher in front of it
+ export _sev_first_display=
+ _sev_refresh_gpgagent= source ${ZDOTDIR:-~}/.zprofile
+} elif [[ ! -o login && $SHLVL -eq 1 && ${+TERMUX_VERSION} -eq 0 ]] {
+ ### early zprofile sourcing for first shell even if not a login shell
+ source ${ZDOTDIR:-~}/.zprofile
+}