Fix bug with ascii size, the pure bash solution counted the file a little weirdly causing issues for some ascii art
This commit is contained in:
parent
4dfa6863d6
commit
eeefd05b8e
15
neofetch
15
neofetch
|
@ -2126,16 +2126,13 @@ getascii () {
|
||||||
# Turn the file into a variable and strip escape codes.
|
# Turn the file into a variable and strip escape codes.
|
||||||
ascii_strip=$(<"$ascii")
|
ascii_strip=$(<"$ascii")
|
||||||
ascii_strip=${ascii_strip//\$\{??\}}
|
ascii_strip=${ascii_strip//\$\{??\}}
|
||||||
ascii_strip=${ascii_strip//\\\\/ }
|
ascii_strip=${ascii_strip//'\\'/ }
|
||||||
ascii_strip=${ascii_strip//\\}
|
ascii_strip=${ascii_strip//'\'}
|
||||||
|
|
||||||
# Get length of longest line
|
# Get ascii file size in rows/cols
|
||||||
# Get lines/columns of the ascii file in pure bash.
|
ascii_size="$(awk 'END {printf NR " "}length>max{max=length}END{printf max}' <<< "$ascii_strip")"
|
||||||
while read -r line 2>/dev/null; do
|
lines=${ascii_size/ *}
|
||||||
[ ${#line} -gt ${ascii_length:-0} ] && ascii_length=${#line}
|
ascii_length=${ascii_size/$lines}
|
||||||
lines=$((lines+=1))
|
|
||||||
done <<< "$ascii_strip"
|
|
||||||
lines=$((lines+=1))
|
|
||||||
|
|
||||||
padding="\033[$((ascii_length + gap))C"
|
padding="\033[$((ascii_length + gap))C"
|
||||||
printf "%b%s" "$print"
|
printf "%b%s" "$print"
|
||||||
|
|
Reference in New Issue