X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/ec83dc0c32145411905204309a6eadfbfa3e17b3..715a3ed9b065c1709547bfcfa6828dbac8d23de3:/base/.zlogout?ds=sidebyside diff --git a/base/.zlogout b/base/.zlogout index 9e0ed3f..3b09ce5 100644 --- a/base/.zlogout +++ b/base/.zlogout @@ -1,4 +1,23 @@ -echo logout +# 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=) +} + +[[ -o interactive ]] && echo logout clear ### load site-specific