From e16e05d1d4a3e005cdf3af6420ad631f1459adaf Mon Sep 17 00:00:00 2001 From: Ethan P Date: Fri, 2 Apr 2021 16:09:24 -0700 Subject: [PATCH] lib: Add 'term_clear' function to clear the terminal screen --- lib/term.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/term.sh b/lib/term.sh index 187455f..7936c70 100644 --- a/lib/term.sh +++ b/lib/term.sh @@ -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" +}