From cf95f70f85b73682851d147d0b47258729abc80e Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 29 May 2016 10:03:18 +1000 Subject: [PATCH] Fix issues with color blocks adding random newlines to the terminal --- neofetch | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/neofetch b/neofetch index 38befad0..7e8aeb5f 100755 --- a/neofetch +++ b/neofetch @@ -2019,17 +2019,16 @@ getcols () { start=$((start+=1)) done - # Add padding and newline to the end of the blocks. - blocks+="${clear}\n${padding}" - blocks2+="${clear}\n${padding}" - # Convert height into spaces. - cols="$(printf "%${block_height}s")" - cols2="$(printf "%${block_height}s")" + spaces="$(printf "%${block_height}s")" - # Print the blocks. - cols=${cols// /${blocks}} - cols+=${cols2// /${blocks2}} + # Convert the spaces into rows of blocks. + [ ! -z "$blocks" ] && cols+=${spaces// /${blocks}${clear}nl} + [ ! -z "$blocks2" ] && cols+=${spaces// /${blocks2}${clear}nl} + + # Add newlines to the string. + cols=${cols%%'nl'} + cols=${cols//nl/\\n${padding}} fi }