From 5c6b680a1eddaa6e17827993fb985ed09fea016b Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 29 Mar 2016 17:57:22 +1100 Subject: [PATCH] Get ascii size in a single wc call --- neofetch | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index 20617e12..1eee8d36 100755 --- a/neofetch +++ b/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