mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-12 15:03:47 -05:00
add _clearLine_
This commit is contained in:
@@ -300,3 +300,22 @@ _columnizeOutput_() {
|
||||
printf "%-${_leftIndent}s%-${_leftColumn}b %b\n" "" "${_key}" "${_line}"
|
||||
done <<<"$(fold -w${_rightWrapLength} -s <<<"${_value}")"
|
||||
}
|
||||
|
||||
_clearLine_() {
|
||||
# DESC:
|
||||
# Clears output in the terminal on the specified line number.
|
||||
# ARGS:
|
||||
# $1 (Optional): Line number to clear. (Defaults to 1)
|
||||
# OUTS:
|
||||
# 0: Success
|
||||
# 1: Failure
|
||||
# USAGE:
|
||||
# _clearLine_ "2"
|
||||
|
||||
[ ! "$(declare -f "_isTerminal_")" ] && fatal "${FUNCNAME[0]} needs function _isTerminal_"
|
||||
|
||||
if _isTerminal_; then
|
||||
local _line=${1:-1}
|
||||
printf "\033[%sA\033[2K" "${_line}"
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user