From eeefd05b8ebe71a4740e01f47fc47c78b37bd582 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 18 May 2016 17:07:55 +1000 Subject: [PATCH] Fix bug with ascii size, the pure bash solution counted the file a little weirdly causing issues for some ascii art --- neofetch | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/neofetch b/neofetch index 9ef4f89f..15d4ee14 100755 --- a/neofetch +++ b/neofetch @@ -2126,16 +2126,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)) + # Get ascii file size in rows/cols + 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"