Last active
November 11, 2021 00:06
-
-
Save philpennock/acf6f7c19664b0ef79b0c1a405848a37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
topleft="$(tput cup 0 0)"; nl="$(tput el)"$'\n'; invis="$(tput civis)"; vis="$(tput cvvis)" | |
push="$(tput sc)"; pop="$(tput rc)" | |
PS1="${topleft}%F{green}%D{%D %r}%f${nl}%~${nl}%# " | |
eval "TRAPUSR1() { print -Pn '${push}${invis}${topleft}%F{green}%D{%D %r}%f${nl}${pop}${vis}' }" | |
unset topleft nl invis vis push pop | |
p=$$; while sleep 1; do kill -s USR1 $p || exit; done &! unset p | |
# modified to do "|| exit" after the kill, so that if the kill fails, the child exits, so when parent dies, child will too. | |
# center-align version | |
topleft="$(tput cup 0 0)"; nl="$(tput el)"$'\n'; invis="$(tput civis)"; vis="$(tput cvvis)" | |
push="$(tput sc)"; pop="$(tput rc)" | |
align="$(printf "%$(((${${=$(stty size)}[2]}-${#${(%):-%D{%D %r\}}})/2))s")" | |
PS1="${topleft}${align}%F{green}%D{%D %r}%f${nl}%~${nl}%# " | |
eval "TRAPUSR1() { print -Pn '${push}${invis}${topleft}${align}%F{green}%D{%D %r}%f${nl}${pop}${vis}' }" | |
unset topleft nl invis vis push pop align | |
p=$$; while sleep 1; do kill -s USR1 $p || exit; done &! unset p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment