From 9d63edcbf7c9d2fef744b11e8644a451824ff010 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 18 May 2016 17:05:32 +1000 Subject: [PATCH] Fix bug with ascii size, the pure bash solution counted the file a little weirdly causing issues for some ascii art --- ascii/distro/windows | 2 +- neofetch | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ascii/distro/windows b/ascii/distro/windows index 4dd86003..1aac3ab8 100644 --- a/ascii/distro/windows +++ b/ascii/distro/windows @@ -3,7 +3,7 @@ ${c1} ,.=:!!t3Z3z., :tt:::tt333EE3 ${c1} Et:::ztt33EEEL${c2} @Ee., .., ${c1} ;tt:::tt333EE7${c2} ;EEEEEEttttt33# -${c1} :Et:::zt333EEQ.${c2} \$EEEEEttttt33QL +${c1} :Et:::zt333EEQ.${c2} $EEEEEttttt33QL ${c1} it::::tt333EEF${c2} @EEEEEEttttt33F ${c1} ;3=*^\`\`\`\"*4EEV${c2} :EEEEEEttttt33@. ${c3} ,.=::::!t=., ${c1}\`${c2} @EEEEEEtttz33QF diff --git a/neofetch b/neofetch index bdac6c4e..058e940b 100755 --- a/neofetch +++ b/neofetch @@ -2204,16 +2204,13 @@ getascii () { # Turn the file into a variable and strip escape codes. ascii_strip=$(<"$ascii") 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 lines/columns of the ascii file in pure bash. - while read -r line 2>/dev/null; do - [ ${#line} -gt ${ascii_length:-0} ] && ascii_length=${#line} - lines=$((lines+=1)) - done <<< "$ascii_strip" - lines=$((lines+=1)) + ascii_size="$(awk 'END {printf NR " "}length>max{max=length}END{printf max}' <<< "$ascii_strip")" + lines=${ascii_size/ *} + ascii_length=${ascii_size/$lines} padding="\033[$((ascii_length + gap))C" printf "%b%s" "$print"