# XXX: only call after relevant vars have been set up, defined early so that
# below code can utilize it after they do so
function _sev_zcleanup {
+ local x p y
+
# gpg forwarding
if [[ -d $_sev_gpg_forward_dir && ( -z $1 || $1 == 'gpg-forward' ) ]] {
# clean up forward dirs if its session is dead or we ask for it
}
}
# reset GNUPGHOME if we removed our own dir
- if [[ $GNUPGHOME =~ '/.ssh_forward/\d+/*$' && ! -e $GNUPGHOME ]]
+ if [[ $GNUPGHOME =~ '/.ssh_forward/\d+/*$' && ! -d $GNUPGHOME ]]
GNUPGHOME=${GNUPGHOME%$MATCH}
}
}
}
}
-
- unset x p y
}
function _sev_setpath {
# remove any further occurences to capture elements from the old PATH
# that we did not anticipate and shift them to the front, since they are
# probably important to the system
+ # NOTE: tied arrays path and fpath already exist
typeset -gU path fpath
# add as many generic paths as possible to keep the order we want
# NOTE: /usr/{local,pkg,games} are unix/bsdisms
# XXX: PREFIX not validated, non-posix but Termux uses it, maybe others
# XXX: XDG specifies ~/.local/bin as the only user-writable dir for
# executables, but we specify more; technically this is against spec
- syspath=("$path[@]")
- path=({{${_sev_home:-~},~}{/.local,},{$PREFIX,}{,/opt,/usr{,/local,/pkg}}}/{s,}bin
+ local -a syspath=("$path[@]")
+ path=({{${_sev_home:-~},~}{/.local,},{$PREFIX,}{,/opt,/opt/*{/*,},/usr{,/local,/pkg}}}/{s,}bin(N)
{$PREFIX,}/usr/{X11R{7,6}/bin,games}
# emulate Arch Linux flatpak-bindir.sh for use on other systems
{${XDG_DATA_HOME:-~/.local/share},{$PREFIX,}/var/lib}/flatpak/exports/bin)
- ((len=$#path))
+ local -i i len=$#path
path=("$path[@]" "$syspath[@]")
# remove bad paths
for (( i = 1; i <= $#path; i++ )) {
[[ -v _sev_home ]] || export _sev_home=$HOME
## fix broken term
-# NOTE: we do this here instead of .zshrc since we might echo stuff
+# NOTE: we do this here instead of .zshrc since we might print stuff
if [[ -t 1 ]] { # only if stdout is tty
[[ ! -v TERM ]] && export TERM=xterm-256color >/dev/null 2>&1
if [[ $#terminfo -eq 0 ]] {
# chances of that are slim.
if [[ ! -v _sev_tmp ]] {
# create personal TMPDIR under system tmp
- t=${TMPDIR:-${TEMPDIR:-${TEMP:-${TMP:-/tmp}}}}/.home-$LOGNAME
+ t=${TMPDIR:-${TEMPDIR:-${TEMP:-${TMP:-${${TMPPREFIX%/zsh}:-/tmp}}}}}/.home-$LOGNAME
[[ -e $t ]] || mkdir -m700 $t 2>/dev/null
_sev_tmp=~/.local/tmp
if [[ ! -d $t ]] {
print -P "%F{red}!!! Can't create session tmp subdir $t, using $_sev_tmp%f"
t=$_sev_tmp
fi
- export _sev_tmp TMPDIR=$t TEMPDIR=$t TEMP=$t TMP=$t
+ export _sev_tmp TMPDIR=$t TEMPDIR=$t TEMP=$t TMP=$t TMPPREFIX=$t/zsh
}
unset t
}