+### tmp
+# NOTE: specs say that POSIX tmp and XDG runtime directories should exist
+# until the last session is logged out (POSIX can exist for longer).
+# since we can't reliably keep track of sessions in a cross-platform
+# manner, the current implementation should use a separate directory per
+# toplevel session (i.e. SHLVL=1). this should placate most applications,
+# though it is not expressly spec compliant.
+if [[ ! -v _sev_tmp ]] {
+ _sev_tmp=~/tmp
+ # create personal tmp dir
+ t=${TMPDIR:-${TEMP:-${TMP:-/tmp}}}/.home-$LOGNAME
+ [[ ! -e $t ]] && mkdir -m700 $t 2>/dev/null
+ if [[ ! -d $t ]] {
+ [[ -o interactive ]] &&
+ print -P "%F{red}!!! Can't create tmpdir $t%f"
+ # fallback bare directories
+ [[ -h $_sev_tmp ]] && unlink $_sev_tmp 2>/dev/null
+ [[ ! -e $_sev_tmp ]] && mkdir -m700 $_sev_tmp 2>/dev/null
+ }
+ # link home tmp for convenience if there isn't anything meaningful there
+ [[ -h $_sev_tmp || ! -e $_sev_tmp ]] && ln -sfn $t $_sev_tmp 2>/dev/null
+ export _sev_tmp=$(realpath $_sev_tmp)
+ # ensure dir is clean
+ _sev_zcleanup tmp
+ # finally create our subdir for this session
+ h=$_sev_tmp/.session.$$
+ mkdir -m700 $h 2>/dev/null
+ export TMPDIR=$h TEMP=$h TMP=$h
+ unset t h
+}
+
+### xdg