-### check if su
-if [[ -v _sev_olduser && $_sev_olduser != $USERNAME ]] _sev_reset_shell=
-export _sev_olduser=$USERNAME
-
-### exports for all new shells
-if [[ -v _sev_reset_shell || $SHLVL == 1 ]] {
- ## lang
- export CHARSET=UTF-8
- export LANG=en_US.UTF-8
- export LC_CTYPE=$LANG
-
- ## path
- typeset -U path fpath
- if [[ $SHLVL == 1 ]] {
- # take a backup before any customizations
- export _sev_sys_PATH=$PATH
- export _sev_sys_FPATH=$FPATH
- }
- # /usr/{pkg,local,games} are unix/bsdisms
- path=({~/,/,/usr/}sbin {~/,/,/usr/}bin /usr/pkg/{s,}bin /usr/X11R{7,6}/bin
- /usr/local/{s,}bin /usr/games)
- PATH=$PATH:$_sev_sys_PATH
- fpath=(${ZDOTDIR:-$HOME/.zsh}/functions/{*,Completions/*}(N))
- #fpath is not exported by default
- export FPATH=$FPATH:$_sev_sys_FPATH
- # take another backup, explained in .zprofile
- typeset -U _backup_path
- _backup_path=("${path[@]}")
-
- ## xdg
- export XDG_CONFIG_HOME=~/etc
- export XDG_CONFIG_DIRS=~/.config:/usr/pkg/etc/xdg:/usr/local/etc/xdg:/etc/xdg
- export XDG_DATA_HOME=~/share
- export XDG_DATA_DIRS=~/.local/share:/usr/pkg/share:/usr/local/share:/usr/share
- export XDG_CACHE_HOME=~/tmp
- export XDG_RUNTIME_DIR=~/tmp
-
- ## create tmp link
- t=${TMPDIR:-/tmp}/home-$LOGNAME
- h=$HOME/tmp
- if [[ ! -e $t ]] {
- mkdir -m 700 $t > /dev/null 2>&1
- # TODO: check if dir exists after mkdir
- }
- # allow opaque entries to override link creation
- if [[ ! -e $h ]] {
- ln -sf $t $h > /dev/null 2>&1
- }
- unset t h