Get ascii size in a single wc call
This commit is contained in:
parent
059eb0eec0
commit
5c6b680a1e
11
neofetch
11
neofetch
|
@ -1852,15 +1852,14 @@ getascii () {
|
|||
export LC_ALL="$SYS_LOCALE"
|
||||
|
||||
# Turn the file into a variable and strip escape codes.
|
||||
ascii_strip=$(<"$ascii")
|
||||
ascii_strip=$(<"${ascii}")
|
||||
ascii_strip=${ascii_strip//\$\{??\}}
|
||||
ascii_strip=${ascii_strip//\\}
|
||||
|
||||
# Get length of longest line
|
||||
length="$(wc -L 2>/dev/null <<< "$ascii_strip")"
|
||||
|
||||
# Get the height in lines
|
||||
lines="$(($(wc -l 2>/dev/null <<< "$ascii_strip") + 1))"
|
||||
ascii_size=($(wc -lL 2>/dev/null <<< "$ascii_strip"))
|
||||
ascii_length=${ascii_size[0]}
|
||||
ascii_height=${ascii_size[1]}
|
||||
|
||||
# Fallback to using awk on systems without 'wc -L'
|
||||
[ -z "$length" ] && \
|
||||
|
@ -2851,7 +2850,7 @@ if [ "$image" != "off" ]; then
|
|||
[ -z "$info_height" ] && info_height=0
|
||||
|
||||
# Set cursor position dynamically based on height of ascii/text.
|
||||
[ "$lines" -lt "$info_height" ] && lines="$info_height"
|
||||
[ "$ascii_length" -lt "$info_height" ] && lines="$info_height"
|
||||
|
||||
printf "%b%s" "\033[${lines}H\033[${prompt_height}A"
|
||||
fi
|
||||
|
|
Reference in New Issue