X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/4ced48ed9172523adccbd9b8cc7c6d8448aaaf65..e122ce754424f4a330d9d7fbeee43cd6dec0892e:/etc/zsh/.zlogout?ds=sidebyside diff --git a/etc/zsh/.zlogout b/etc/zsh/.zlogout index c005421..1b2b266 100644 --- a/etc/zsh/.zlogout +++ b/etc/zsh/.zlogout @@ -10,9 +10,34 @@ _sev_zcleanup ## clean up any remaining sockets from gpg forwarding [[ -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 -n '\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 -n '\e[2J' + } echo logout - clear } ### load site-specific