diff options
author | davidovski <david@davidovski.xyz> | 2022-10-06 08:48:04 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2023-05-17 16:50:26 +0000 |
commit | 3272a63cf1dcc23252ffebb792466b797ad3a146 (patch) | |
tree | 759003c3935720555f6c4ded3d4256f05bf3345a /src/util | |
parent | 797b98a68976b4bb183292eacfa8a2636b82c00e (diff) |
Fixed hbar printing issue
Diffstat (limited to 'src/util')
-rwxr-xr-x | src/util/hbar.sh | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/util/hbar.sh b/src/util/hbar.sh index 25343bd..603f66a 100755 --- a/src/util/hbar.sh +++ b/src/util/hbar.sh @@ -1,5 +1,6 @@ #!/bin/sh . /usr/lib/colors.sh +. /usr/lib/xilib.sh move_up () { [ ! "$1" = "-1" ] && @@ -8,7 +9,7 @@ move_up () { move_down () { [ ! "$1" = "-1" ] && - printf "\033[%dA" "$1" + printf "\033[%dB" "$1" } count_string () { @@ -26,13 +27,13 @@ count_string () { hbar () { local width terminate human text color reset unit line count width=$(tput cols) - color=$BG_BLUE - reset=$BG_DEFAULT + color="$BLACK$BG_WHITE" + reset="$WHITE$BG_DEFAULT" terminate=false human=false line=0 - while getopts ":T:c:r:u:l:ht" opt; do + while getopts "T:c:r:u:l:ht" opt; do case "$opt" in T) text="$OPTARG" @@ -81,7 +82,12 @@ hbar () { while [ "$i" -lt "$width" ]; do [ "$i" = "$reset_at" ] && printf "$reset" - printf " " + [ "${#text}" -gt 0 ] && { + printf "%s" "${text%%${text#?}}" + text="${text#?}" + } || { + printf " " + } i=$((i+1)) done @@ -92,4 +98,4 @@ hbar () { exit 0 } -hbar $@ +printf "%s" "$(hbar "$@")" |