lib: Add 'term_clear' function to clear the terminal screen

This commit is contained in:
Ethan P 2021-04-02 16:09:24 -07:00
parent 93e2e4d048
commit e16e05d1d4
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA

View File

@ -1,9 +1,9 @@
# -----------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------------
# bat-extras | Copyright (C) 2020 eth-p | MIT License
#
# Repository: https://github.com/eth-p/bat-extras
# Issues: https://github.com/eth-p/bat-extras/issues
# -----------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------------
# Gets the width of the terminal.
# This will return 80 unless stdin is attached to the terminal.
@ -21,3 +21,8 @@ term_width() {
fi
return 0
}
# Clears the terminal using the ANSI escape sequences for erase screen and cursor absolute positioning.
term_clear() {
printf "\x1B[3J\x1B[2J\x1B[H"
}