Last active
August 6, 2023 20:27
-
-
Save eric-glb/0291877675663ed0a17cea1d029ebdb9 to your computer and use it in GitHub Desktop.
Bash: show a notification in the terminal's last line
This file contains hidden or 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
| write_message() { | |
| local message | |
| message=" ${*} " | |
| __write() { | |
| local reset col_bg col_fg | |
| reset="$(tput sgr0)" | |
| col_bg="$(tput setab 4)" | |
| col_fg="$(tput setaf 0)" | |
| [[ "${2-}" == "--no-background" ]] && unset col_bg | |
| tput sc | |
| tput cup "${LINES}" "$((COLUMNS - ${#message}))" | |
| printf "${col_bg}${col_fg}%s${reset}" "${message}" | |
| tput rc | |
| } | |
| __clean_up() { | |
| local blank_spaces | |
| blank_spaces="$(printf "%${#message}s")" | |
| sleep 5 | |
| __write "${blank_spaces}" --no-background | |
| } | |
| __write "${message}" | |
| (__clean_up &) | |
| unset -f __write __clean_up | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From: https://gist.github.com/sebastiancarlos/ca7124e33d4af1afcf3f29b01f5deadd