From f96eb605d0f64efd3a6eee0c34d74388de93e2ad Mon Sep 17 00:00:00 2001 From: tfa Date: Thu, 23 Nov 2023 15:38:05 +0100 Subject: [PATCH] =?UTF-8?q?Adaptation=20=C3=A0=20la=20largeur=20du=20termi?= =?UTF-8?q?nal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fip.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fip.sh b/fip.sh index 3b2dc83..83f98e3 100755 --- a/fip.sh +++ b/fip.sh @@ -26,8 +26,11 @@ function print_data() { slug="\033[1;${color_code}m$slug\033[0m" slug=$(printf "%-32s" "$slug") - artiste=$(printf "%-40s" "$artiste") - titre=$(printf "%-40s" "$titre") + terminal_width=$(tput cols) + width=$((((terminal_width - 32) / 2) - 4)) + artiste=$(printf "%-${width}s" "${artiste:0:${width}}") + titre=$(printf "%-${width}s" "${titre:0:${width}}") + output+="\033[1$slug\033[0m | \033[1mArtiste:\033[0m $artiste | \033[1mTitre:\033[0m $titre |\n" color_index=$(get_next_color "$color_index") done