X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/8d4a98e19ec40334ed8e8f2ce4e5a9f094bdbcaf..e226ac038cb5616a177678c19023b639c3e9ef1c:/etc/zsh/.zlogout?ds=sidebyside diff --git a/etc/zsh/.zlogout b/etc/zsh/.zlogout index 1ede4c5..8ab31d1 100644 --- a/etc/zsh/.zlogout +++ b/etc/zsh/.zlogout @@ -5,16 +5,40 @@ # 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 +[[ XDG_CACHE_HOME = $_sev_tmp/.xdg.cache ]] && unset XDG_CACHE_DIR +[[ XDG_RUNTIME_DIR = $TMPDIR/.xdg.runtime ]] && unset XDG_RUNTIME_DIR ## clean up any remaining sockets from gpg forwarding -[[ -v _GNUPG_SOCK_DEST_BASE ]] && rm -f $_GNUPG_SOCK_DEST_BASE*(N=) +[[ -v _GNUPG_SOCK_DEST_BASE ]] && rm -f $_GNUPG_SOCK_DEST_BASE*(=N) +## manually reset terminal for interactive logout if [[ -o interactive ]] { + # send xterm scrollback clear extension just in case: + # - TERM may not be set correctly + # - terminfo/termcap database entry for reset may be buggy + echo -en '\e[3J' + # use terminfo/termcap directly instead of relying on system clear/reset: + # - often they are just wrappers for ncurses tput or other tools + # - they may not even exist on lightweight systems + # - provided scripts/binaries may be buggy or broken + y=0 + for x (rs1 rs2 rs3) { + [[ -v terminfo[$x] ]] || continue + echoti $x + y=1 + } + if (( y == 0 )) { + for x (rs r1 r2 r3) { + [[ -v termcap[$x] ]] || continue + echotc $x + y=1 + } + } + if (( y == 0 )) { + # fallback, send ECMA-48 clear + echo -en '\e[2J' + } echo logout - clear } ### load site-specific -if [[ -f ${ZDOTDIR:-~}/.zlogout.local ]] { source ${ZDOTDIR:-~}/.zlogout.local } - -# vim: et sts=4 sw=4 ts=8 tw=79 +load-site-dotfile zlogout