X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/833b2af31c59941e1bdfed4f67d70cf20a40d2a9..e6e7ad69b69cc308652bbf7cc30c851b35933dc4:/base/.zlogout?ds=sidebyside diff --git a/base/.zlogout b/base/.zlogout index 6e7b474..64591b6 100644 --- a/base/.zlogout +++ b/base/.zlogout @@ -1,32 +1,13 @@ -# NOTE: for the cleanups below, even if our shell is not the one that spawned -# the directory, SHLVL == 1 means that it should be safe to clean it up. -# since .zlogout isn't guaranteed to have been run in the same shell as -# our .zprofile was (since we source it in .zshenv) it has to be done -# like this. - -### gpg forward cleanup -if [[ $SHLVL == 1 && $GNUPGHOME =~ '/.ssh_forward/\d+/*$' ]] { - x=$GNUPGHOME - # reset GNUPGHOME - [[ -o GLOB_ASSIGN ]]; y=$? - setopt GLOB_ASSIGN - GNUPGHOME=$GNUPGHOME/../..(:a) - [[ $y != 0 ]] && unsetopt GLOB_ASSIGN - # clean dir if it exists - if [[ -d $x ]] { - find $x -mindepth 1 -maxdepth 1 | while read -r y; do - unlink $y - done - rmdir -p $x 2>/dev/null - } - # clean up any remaining sockets from gpg forwarding - rm -f $_GNUPG_SOCK_DEST_BASE*(N=) -} - -### remove tmp runtime if our shell spawned it -if [[ $SHLVL == 1 && $TMPDIR =~ '/.session.\d+/*$' ]] { - rm -rf $TMPDIR 2>/dev/null -} +### cleanup +# XXX: since .zlogout isn't guaranteed to have been run in the same shell as +# our .zprofile was (since we source it in .zshenv for SHLVL=1 among other +# situations) we are not guaranteed to clean up our current session's tmp, +# but it should be cleared out on next session launch +_sev_zcleanup +## unset vars that use our tmp since above will remove them +unset XDG_CACHE_HOME XDG_RUNTIME_DIR +## clean up any remaining sockets from gpg forwarding +[[ -v _GNUPG_SOCK_DEST_BASE ]] && rm -f $_GNUPG_SOCK_DEST_BASE*(N=) if [[ -o interactive ]] { echo logout